Jump to content

FROM_UNIXTIME () Help!


tomhoad

Recommended Posts

Hi,

 

Long time since I've done PHP programming - PHP5 has come out since...

 

Anyway, I'm having some trouble echoing a UNIX TIMESTAMP from my database. The timestamp is getting there fine, phpmyadmin is saying so, in the format 2007-21-11 23:27:00 etc.

 

However, when I recall this from the database with...

 

$query   = "SELECT title, content, FROM_UNIXTIME(date, '%W %D %M %Y') as dttm 
FROM news ORDER BY date"; 

 

...I get the date as "Wednesday 31st December 1969". Which unless I've gone back in time, is not the date.

 

Any help appreciated! I've heard there's quirks in how php5 now deals with time queries compared to php4, so maybe im just not up to date - or maybe im just plain wrong!

 

Cheers!!

 

 

Link to comment
https://forums.phpfreaks.com/topic/78333-from_unixtime-help/
Share on other sites

That is a MySQL command and not PHP, but from what I understand, you are trying to use a MySQL date in a Unix Timestamp function, which won't work.  If you want to use FROM_UNIXTIME(), the arguement has to be in a unix time format first and the way you are calling it, it isn't.

 

So either convert it first or use a MySQL DATE function instead.

Link to comment
https://forums.phpfreaks.com/topic/78333-from_unixtime-help/#findComment-396360
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.