Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.