Jump to content

[SOLVED] Invalid date/time being displayed


rkstevens

Recommended Posts

I have the following code:

$formatdate = "l F n, Y g:ia";
echo (date($formatdate,$concertinfo[EventDate]));

$concertinfo[EventDate] is a timestamp stored in a database with the value of: 2008-08-20 20:00:00

but when I display it using the above date function, I get: Wednesday December 12, 1969 7:33pm

 

What do I have wrong?

 

Link to comment
https://forums.phpfreaks.com/topic/104398-solved-invalid-datetime-being-displayed/
Share on other sites

Ummm. The php date() function takes a Unix Timestamp as the second parameter. You are giving it a yyyy-mm-dd hh:mm:ss value.

 

To format a DATETIME from your database, use the mysql DATE_FORMAT() function directly in the query - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format

 

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.