note 14874 deleted from ref.datetime by vincent

From: Date: Thu, 11 Sep 2003 11:53:33 +0000
Subject: note 14874 deleted from ref.datetime by vincent
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-56077@lists.php.net to get a copy of this message
Note Submitter: william@ScriptingBiz.Com ---- [Editor's note: a simpler and more efficient solution is to use the UNIX_TIMESTAMP(fieldname) function in MySQL when performing a SELECT query. This is documented in the MySQL manual.] Ever use the mysql column type of "timestamp"? It crams all the digits fo the date/time togeter and makes it hard to deal with. Here's a solution: ##################################################################### // myts_date is identical to date except that it takes a // mysql timestamp instead of epoch seconds for an argument // written by William Janoch - william@ScriptingBiz.Com // // I write "clever little" code that never // complains when the sky isn't falling. // /* see also "chicken little" code */ function myts_date($format,$mytimestamp) { $month = substr($mytimestamp,4,2); $day = substr($mytimestamp,6,2); $year = substr($mytimestamp,0,4); $hour = substr($mytimestamp,8,2); $min = substr($mytimestamp,10,2); $sec = substr($mytimestamp,12,2); $epoch = mktime($hour,$min,$sec,$month,$day,$year); $date = date ($format, $epoch); return $date; } #####################################################################

« previous php.notes (#56077) next »