note 115938 added to function.checkdate

From: Date: Thu, 16 Oct 2014 16:07:54 +0000
Subject: note 115938 added to function.checkdate
Groups: php.notes 
Request: Send a blank email to php-notes+get-200665@lists.php.net to get a copy of this message
Super graceful solution by glavic and the mod by Bas - the only thing I would add is if you have user input, you have the potential for really munged up values for date which can throw exceptions. Add a try/catch: if (((int) $version[0] >= 5 && (int) $version[1] >= 2 && (int) $version[2] > 17)) { try { $d = DateTime::createFromFormat($format, $date); } catch (Exception $e) { if ($debug) { echo "Invalid date: " . $e->getMessage() . "<br>\n"; } return false; } } else { try { $d = new DateTime(date($format, strtotime($date))); } catch (Exception $e) { if ($debug) { echo "Invalid date: " . $e->getMessage() . "<br>\n"; } return false; } } ---- Server IP: 72.52.91.14 Probable Submitter: 67.108.20.250 ---- Manual Page -- http://php.net/manual/en/function.checkdate.php Edit -- https://master.php.net/note/edit/115938 Del: integrated -- https://master.php.net/note/delete/115938/integrated Del: useless -- https://master.php.net/note/delete/115938/useless Del: bad code -- https://master.php.net/note/delete/115938/bad+code Del: spam -- https://master.php.net/note/delete/115938/spam Del: non-english -- https://master.php.net/note/delete/115938/non-english Del: in docs -- https://master.php.net/note/delete/115938/in+docs Del: other reasons-- https://master.php.net/note/delete/115938 Reject -- https://master.php.net/note/reject/115938 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200665) next »