PDA

View Full Version : PHP/MySQL time and date question...


scott_allen13
01-10-2007, 04:25 AM
i know this isn't completely flash related, but i figure i can get a quick answer here.

i have installed message board software in which the "last_post" field is type int(10) unsigned and has contents like "1168398912." can someone explain to me how that number creates the date and time? i can't figure out what to search for to get info on it...

thanks,

scott

DilutedImage
01-10-2007, 04:39 AM
It's a Unix timestamp ... It's the number of seconds that have elapsed since January 01, 1970. .. That timestamp is 9:15pm, today.

CyanBlue
01-10-2007, 04:41 AM
Yup... Google with 'unix time' for more information on that...
http://en.wikipedia.org/wiki/Unix_time

DilutedImage
01-10-2007, 04:44 AM
Read this: PHP and the UNIX Timestamp (http://www.kirupa.com/web/php_unix_timestamp.htm)

scott_allen13
01-10-2007, 09:48 PM
thanks guys...

from the looks of things, i can get that from php by saying


$now = date('U');

or convert back to normal with...

$convertedDate = date('Y-m-d H:i:s', $unixDate);


sound about right?

scott

DilutedImage
01-11-2007, 07:35 AM
Yep. You can also get a current timestamp with time(). Here are the appropriate documentation pages:

Date() (http://www.php.net/date)
Time() (http://www.php.net/time)