note 98068 deleted from function.strtotime by danbrown
| From: | danbrown@php.net | Date: | Mon, 24 May 2010 14:04:33 +0000 |
| Subject: | note 98068 deleted from function.strtotime by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-169557@lists.php.net to get a copy of this message | ||
Note Submitter: koen at thomeer dot be
----
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
};
?>