note 103871 added to function.strtotime

From: Date: Sat, 07 May 2011 22:33:16 +0000
Subject: note 103871 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-179533@lists.php.net to get a copy of this message
Using PHP 5.3.2-1ubuntu4.7, I observed some strangeness with strtotime, it seemed to misinterpret dates with periods: $formatted = date( 'Y-m-d H:i:s', strtotime($anyFormat) ); This would sometimes return '1970-01-01 00:00:00' (timestamp of 0), or the current day with different times attached. The dates were being misinterpreted as times, which are accepted in the format of ( 't'? HH [.:] MM [.:] II ), and the date was assumed to be the current date. In other cases when the times were invalid (e.g. in 2010.03.01, HH = 2010 > 24), I got a timestamp of 0. Fix: Replace dots with slashes, then call date with that. $fixedAnyFormat = str_replace( '.', '/', $anyFormat ); ---- Server IP: 69.147.83.197 Probable Submitter: 70.36.146.161 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/103871 Del: integrated -- https://master.php.net/note/delete/103871/integrated Del: useless -- https://master.php.net/note/delete/103871/useless Del: bad code -- https://master.php.net/note/delete/103871/bad+code Del: spam -- https://master.php.net/note/delete/103871/spam Del: non-english -- https://master.php.net/note/delete/103871/non-english Del: in docs -- https://master.php.net/note/delete/103871/in+docs Del: other reasons-- https://master.php.net/note/delete/103871 Reject -- https://master.php.net/note/reject/103871 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179533) next »