mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
DateTime::getTimestamp() is PHP5.3+
This commit is contained in:
parent
5e00fdfce5
commit
8bd1980dd4
2 changed files with 4 additions and 4 deletions
|
@ -846,7 +846,7 @@ class CakeTimeTest extends CakeTestCase {
|
|||
$date = new DateTime('+1 hour', new DateTimeZone('America/New_York'));
|
||||
$result = $this->Time->fromString($date, 'UTC');
|
||||
$date->setTimezone(new DateTimeZone('UTC'));
|
||||
$expected = $date->getTimestamp() + $date->getOffset();
|
||||
$expected = $date->format('U') + $date->getOffset();
|
||||
|
||||
$this->assertWithinMargin($expected, $result, 1);
|
||||
|
||||
|
@ -871,7 +871,7 @@ class CakeTimeTest extends CakeTestCase {
|
|||
Configure::write('Config.timezone', date_default_timezone_get());
|
||||
$date = new DateTime('2013-04-09');
|
||||
$result = $this->Time->fromString($date);
|
||||
$this->assertEquals($result, $date->getTimestamp());
|
||||
$this->assertEquals($result, $date->format('U'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -325,9 +325,9 @@ class CakeTime {
|
|||
) {
|
||||
$clone = clone $dateString;
|
||||
$clone->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
$date = (int)$clone->getTimestamp() + $clone->getOffset();
|
||||
$date = (int)$clone->format('U') + $clone->getOffset();
|
||||
} elseif ($dateString instanceof DateTime) {
|
||||
$date = (int)$dateString->getTimeStamp();
|
||||
$date = (int)$dateString->format('U');
|
||||
} else {
|
||||
$date = strtotime($dateString);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue