Re: timestamp iin MySQL not compatible to the one in PHP???

From: Date: Wed, 06 Mar 2002 00:23:09 +0000
Subject: Re: timestamp iin MySQL not compatible to the one in PHP???
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-87387@lists.php.net to get a copy of this message
The long way, but it will help in the understanding of it: $timestamp = "20020305211704"; $year = substr($timestamp, 0, 4); $month = substr($timestamp, 4, 2); $day = substr($timestamp, 6, 2); $hour = substr($timestamp, 8, 2); $minute = substr($timestamp, 10, 2); $second = substr($timestamp, 12, 2); $utime = mktime($hour, $minute, $second, $month, $day, $year); $longdate = date('l, F jS, Y @ g:i:sp'); echo $longdate; Will produce: Tuesday, March 5th, 2002 @ 9:17:04pm Mike Andy wrote:
So what is the proper function in PHP to convert the MySQL timestamp into a proper format like Sonday, Apr. 20th 2002? Thanx, Andy "Jason Wong" <php-general@gremlins.com.hk> schrieb im Newsbeitrag news:php.db-17490@news.php.net...
On Wednesday 06 March 2002 04:31, Andy wrote:
Hi there, I am playing around with the timestamp functions. I created a timestamp with mysql ( the row is timestamp) and do reformat this thing after selecting with php in the folowíng way: $date_posted[$i] = strftime("%A, %d-%m-%Y %R", $date_posted[$i]); This always returns Tuesday, 19-01-2038 but the mysql timestamp says: 20020305211704
They return the time in different formats. Read the MySQL manual then read the PHP manual (or vice-versa). The MySQL timestamp is human readable. So in your example above: 20020305211704 ==> 2002-03-05 21:17:04 time() in PHP is the number of seconds since the Unix Epoch. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* But, officer, he's not drunk, I just saw his fingers twitch! */


« previous php.general (#87387) next »