note 51956 added to function.strtotime

From: Date: Sat, 16 Apr 2005 23:04:55 +0000
Subject: note 51956 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-88092@lists.php.net to get a copy of this message
Quick solution to strtotime() function returning wrong results(for PHP4 and below) when it tries to "guess what you meant" and will successfully parse dates that would otherwise be considered invalid...just dont use it, this works better: function valid_date($thedate) { list($year, $month, $day) = sscanf($thedate, "%d-%d-%d"); return checkdate($month, $day, $year); } "2005-11-25" returns TRUE "2005-11-32" returns FALSE ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51956 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51956&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51956&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51956&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51956&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51956&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51956&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88092) next »