$php_mysql$ Posted July 13, 2011 Share Posted July 13, 2011 when i use date('F jS, Y, g:i a',$d['datetime']) i get January 1st, 1970, 12:33 am but if i only use $d['datetime'] then i get correct date and time like 2011-07-13 01:47:60 whats the issue here? Link to comment https://forums.phpfreaks.com/topic/241897-date-function-printing-wrong-info/ Share on other sites More sharing options...
max_w1 Posted July 13, 2011 Share Posted July 13, 2011 Are you running this page on the local host? and what is the time on your computer? Link to comment https://forums.phpfreaks.com/topic/241897-date-function-printing-wrong-info/#findComment-1242225 Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2011 Share Posted July 13, 2011 The second parameter of the date function is expected to be a Unix Timestamp. You can use the strtotime function to convert your $d['datetime'] value into a Unix Timestamp, or since you are apparently getting this value from a query statement, you can retrieve the value in the final format you want from your query using the mysql DATE_FORMAT function - http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format (doing this in a query is at least 8 times faster than using some slow parsed, tokenized, interpreted php code.) Link to comment https://forums.phpfreaks.com/topic/241897-date-function-printing-wrong-info/#findComment-1242228 Share on other sites More sharing options...
$php_mysql$ Posted July 13, 2011 Author Share Posted July 13, 2011 max yes using it on wamp and time is exact 2011-07-13 01:47:60 without using the date function Link to comment https://forums.phpfreaks.com/topic/241897-date-function-printing-wrong-info/#findComment-1242231 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.