Skip to content
Permalink
Browse files

Added workaround for strtotime("0000-00-00 00:00:00") returning -6216…

…9955200 on a 64 bit system
  • Loading branch information...
Mark van Driel Mark van Driel
Mark van Driel authored and Mark van Driel committed Aug 15, 2013
1 parent 559fb58 commit 1595287290b6daa2f26c93b529c82882537b2b7e
Showing with 9 additions and 1 deletion.
  1. +3 −0 lib/Cake/Test/Case/Utility/CakeTimeTest.php
  2. +6 −1 lib/Cake/Utility/CakeTime.php
@@ -583,6 +583,9 @@ public function testFormat() {
$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);
}
/**
@@ -328,7 +328,12 @@ public static function fromString($dateString, $timezone = null) {
} 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)) {

0 comments on commit 1595287

Please sign in to comment.
You can’t perform that action at this time.