note 37031 deleted from function.date by nlopess

From: Date: Wed, 07 Jan 2004 19:24:15 +0000
Subject: note 37031 deleted from function.date by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-63099@lists.php.net to get a copy of this message
Note Submitter: fireball@sizzling.com ---- Under 4.3.3 I found that mktime() doesn't work very well when working with a normal datetime fields in mysql. The normal format of these are "2003-10-30 10:09:00". Using strtotime() works much better: $time = "2003-10-30 10:09:00"; echo date("F dS, Y h:ia",strtotime($time)); will output a correct date: October 30th, 2003 10:09am where as: $time = "2003-10-30 10:09:00"; list($date1,$time1) = explode(" ",$time); list($year,$month,$day) = explode("-",$date1); list($hour,$min,$sec) = explode(":",$time1); $arr = array($hour,$min,$sec,$month,$day,$year); $time = implode(",",$arr); echo date("F dS, Y h:ia", mktime($time)); will produce an incorrect, changing date e.g.: October 31st, 2003 10:14am

« previous php.notes (#63099) next »