note 61132 deleted from function.strtotime by derick
| From: | derick@php.net | Date: | Sun, 15 Jul 2007 12:39:58 +0000 |
| Subject: | note 61132 deleted from function.strtotime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-128560@lists.php.net to get a copy of this message | ||
Note Submitter: Paul Wib
----
Slight tweak to ScottB's function for UK dates below. Accounts for when a year isn't
provided:
function strtotime_uk($str)
{
$str = preg_replace("/^\s*([0-9]{1,2})[\/\. -]+([0-9]{1,2})[\/\. -]*([0-9]{0,4})/",
"\\2/\\1/\\3", $str);
$str = trim($str,'/');
echo "Converted to UK date: $str<br>";
return strtotime($str);
}
As strtotime, if the year isn't provided it will default to current year:
strtotime_uk("13/11"); // 13th November, UK-style