handling totally absent dates in _strtotime, return current timestamp is all failes

This commit is contained in:
Klaus Leithoff 2010-09-06 13:05:19 +00:00
parent ead7f146a9
commit 2228cb11cc

View File

@ -2931,6 +2931,7 @@
} }
/** /**
* Helper function to handle wrong or unrecognized timezones * Helper function to handle wrong or unrecognized timezones
* returns the date as it is parseable by strtotime, or current timestamp if everything failes
*/ */
static function _strtotime($date='') static function _strtotime($date='')
{ {
@ -2938,12 +2939,13 @@
{ {
$dtarr = explode(' ',$date); $dtarr = explode(' ',$date);
$test = false; $test = false;
while ($test===false) while ($test===false && count($dtarr)>=1)
{ {
array_pop($dtarr); array_pop($dtarr);
$test=strtotime(implode(' ',$dtarr)); $test=strtotime(implode(' ',$dtarr));
if ($test) $date = implode(' ',$dtarr); if ($test) $date = implode(' ',$dtarr);
} }
if ($test===false) $date = strtotime('now');
} }
return $date; return $date;
} }