tomhoad Posted November 21, 2007 Share Posted November 21, 2007 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!! Quote Link to comment https://forums.phpfreaks.com/topic/78333-from_unixtime-help/ Share on other sites More sharing options...
revraz Posted November 21, 2007 Share Posted November 21, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/78333-from_unixtime-help/#findComment-396360 Share on other sites More sharing options...
BenInBlack Posted November 22, 2007 Share Posted November 22, 2007 UNIXTIME is represented in a number of seconds from a given date, it looks like to me your data in the database is timestamp format, which is not unixtime you should be using SELECT DATE_FORMAT(date, '%W %D %M %Y'); Quote Link to comment https://forums.phpfreaks.com/topic/78333-from_unixtime-help/#findComment-396443 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.