mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Added workaround for strtotime("0000-00-00 00:00:00") returning -62169955200 on a 64 bit system
This commit is contained in:
parent
559fb5805b
commit
1595287290
2 changed files with 9 additions and 1 deletions
|
@ -583,6 +583,9 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Time->format('nonsense', '%d-%m-%Y', 'invalid', 'UTC');
|
$result = $this->Time->format('nonsense', '%d-%m-%Y', 'invalid', 'UTC');
|
||||||
$this->assertEquals('invalid', $result);
|
$this->assertEquals('invalid', $result);
|
||||||
|
|
||||||
|
$result = $this->Time->format('0000-00-00', '%d-%m-%Y', 'invalid');
|
||||||
|
$this->assertEquals('invalid', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -328,7 +328,12 @@ class CakeTime {
|
||||||
} elseif ($dateString instanceof DateTime) {
|
} elseif ($dateString instanceof DateTime) {
|
||||||
$date = (int)$dateString->format('U');
|
$date = (int)$dateString->format('U');
|
||||||
} else {
|
} 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)) {
|
if ($date === -1 || empty($date)) {
|
||||||
|
|
Loading…
Reference in a new issue