note 98068 added to function.strtotime

From: Date: Mon, 24 May 2010 12:44:42 +0000
Subject: note 98068 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-169555@lists.php.net to get a copy of this message
Here is a more advanced example of a version that works for people outside of the US. It can recognise dd-mm-yy and dd/mm/yy. <?php function strtotime_nonus($date) { if(is_null($date) or ($date == "")) return False; if(strpos($date, '/')) { // break out components with '/', maximum of 3 elements $components = explode("/", $date, 3); } elseif(strpos($date, '-')) { // break out components with '-', maximum of 3 elements $components = explode("-", $date, 3); }; $count = count($components); if($count > 1) // There is a slash { $tmp = $components[0]; // Swap first and second components $components[0] = $components[1]; $components[1] = $tmp; } return strtotime(implode("/",$components)); // Put back together }; ?> ---- Server IP: 217.71.118.186 Probable Submitter: 84.196.243.138 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- https://master.php.net/note/edit/98068 Del: integrated -- https://master.php.net/note/delete/98068/integrated Del: useless -- https://master.php.net/note/delete/98068/useless Del: bad code -- https://master.php.net/note/delete/98068/bad+code Del: spam -- https://master.php.net/note/delete/98068/spam Del: non-english -- https://master.php.net/note/delete/98068/non-english Del: in docs -- https://master.php.net/note/delete/98068/in+docs Del: other reasons-- https://master.php.net/note/delete/98068 Reject -- https://master.php.net/note/reject/98068 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169555) next »