Jump to content

DATE_FORMAT Question


beachdaze

Recommended Posts

Trying to change the date format from the default 0000-00-00 00:00:00 to something easier to read. 

Here is the Select statement:

$query = "SELECT (name), (time), (location) FROM main ORDER BY time ASC";

If I add the DATE_FORMAT (time, XXX) etc... (Where XXX is the usual D, Y Etc) I get syntax errors.  Do I need to have a strtotime statement instead??

Link to comment
https://forums.phpfreaks.com/topic/34754-date_format-question/
Share on other sites

Did you try it?
To format a date from MySQL's date format with date(), you do have to use strtotime()

date("Y-m-d", strtotime($date));

If you're working with the empty date, your strtotime() will result in 0, resulting in date thinking it's in 1970, the Unix Epoch. Formatting it using date() won't do you any good.
Link to comment
https://forums.phpfreaks.com/topic/34754-date_format-question/#findComment-163804
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.