Search code examples
phpmysqldatabaseformats

Date Time formats, change formats.


I have a TIMESTAMP in the database for pages, so in this format $d="2011-01-03 12:53:22"

And when i try to send that through date("c",$d) I only get 1970-01-01T10:33:31+10:00

I have read in the php manual that date("c",THIS) must be an INT so what do i use to get the int from "2011-01-03 12:53:22"??


Solution

  • you forget to convert the date string to timestamp when sending for date function

    date('c', strtotime($d));