note 87365 deleted from function.strtotime by danbrown

From: Date: Tue, 02 Dec 2008 15:09:18 +0000
Subject: note 87365 deleted from function.strtotime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147549@lists.php.net to get a copy of this message
Note Submitter: Muhammad Muzzammil ---- ash[at]ashmckenzie[dot]org, edit your code as below and run it. <?php $dates = array('11/12/2008', '12/12/2008', '13/12/2008'); foreach ( $dates as $date ) { $result = strtotime($date); if ( ! $result || $result == -1 ) { $result = 'false/-1'; } print "INFO: $date result=[$result] => " . date('jS \of F Y h:i:s A', $result) . "\n"; } ?> INFO: 11/12/2008 result=[1226448000] => 12th of November 2008 12:00:00 AM INFO: 12/12/2008 result=[1229040000] => 12th of December 2008 12:00:00 AM Warning: date() expects parameter 2 to be long, string given in - on line 6 INFO: 13/12/2008 result=[false/-1] => You'll notice that the date is represented as m/d/y, NOT d/m/y. My guess is that PHP4 'fixes' dates, which means that 13 represents January next year. However, this is not available in PHP5.

« previous php.notes (#147549) next »