Added workaround for strtotime("0000-00-00 00:00:00") returning -62169955200 on a 64 bit system

This commit is contained in:
Mark van Driel 2013-08-15 08:58:05 +02:00
parent 559fb5805b
commit 1595287290
2 changed files with 9 additions and 1 deletions

View file

@ -583,6 +583,9 @@ class CakeTimeTest extends CakeTestCase {
$result = $this->Time->format('nonsense', '%d-%m-%Y', 'invalid', 'UTC');
$this->assertEquals('invalid', $result);
$result = $this->Time->format('0000-00-00', '%d-%m-%Y', 'invalid');
$this->assertEquals('invalid', $result);
}
/**

View file

@ -328,7 +328,12 @@ class CakeTime {
} elseif ($dateString instanceof DateTime) {
$date = (int)$dateString->format('U');
} else {
$date = strtotime($dateString);
// workaround for strtotime("0000-00-00 00:00:00") returning -62169955200 on a 64 bit system.
if (substr($dateString, 0, 10) === '0000-00-00') {
$date = false;
} else {
$date = strtotime($dateString);
}
}
if ($date === -1 || empty($date)) {