RE: [PHP-DB] Date weirdness (php/mysql) (code included)

From: Date: Wed, 08 Nov 2000 21:16:52 +0000
Subject: RE: [PHP-DB] Date weirdness (php/mysql) (code included)
Groups: php.db 
Request: Send a blank email to php-db+get-4316@lists.php.net to get a copy of this message
After a little digging around on the http://www.php.net/manual/function.mktime.php and http://www.php.net/manual/function.strtotime.php pages I came across a solution I can deal with. $fmtdate = ereg_replace('([0-9]*)-([0-9]*)-([0-9]*)','\2/\3/\1', $row[thedate]); (format the date in a way that strtotime() can deal with it) $timestamp = strtotime($fmtdate); (build the timestamp with strtotime()) For some reason this seemed easier than the mktime() method. Either way it worked and I appreciate Rasmus pointing me in the right direction. John Guynn -----Original Message----- From: Rasmus Lerdorf [mailto:rasmus@php.net] Sent: Wednesday, November 08, 2000 3:30 PM To: John Guynn Cc: Php-Db (E-mail) Subject: Re: [PHP-DB] Date weirdness (php/mysql) (code included) Please read: http://www.php.net/manual/function.date.php The second argument to date() is in standard Unix timestamp format. ie. the number of seconds since jan.1 1970. You can use mktime() to generate this timestamp for you.

« previous php.db (#4316) next »