Re: newbie date time question

From: Date: Wed, 22 Jun 2011 23:57:29 +0000
Subject: Re: newbie date time question
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-313670@lists.php.net to get a copy of this message
On 23/06/11 1:02 AM, Stuart Dallas wrote:
On Wednesday, 22 June 2011 at 15:59, David Nicholls wrote:
OK, looks like I have fixed problem, using: $format = 'd/m/Y g:i:s A'; $dt = date_create_from_format($format, $d[0]); $dt2 = date('r', $dt->getTimestamp()); $data[] = array(strtotime($dt2), $d[1]); Not elegant but it gives me the date/time value.
$dt->getTimestamp() will give you the same value as strtotime($dt2), so you don't need the inelegance. $format = 'd/m/Y g:i:s A'; $dt = date_create_from_format($format, $d[0]); $data[] = array($dt->getTimestamp(), $d[1]); -Stuart
Thanks, Stuart. That's much prettier! DN

« previous php.general (#313670) next »