Skip to content
Permalink
Browse files

DateTime::getTimestamp() is PHP5.3+

  • Loading branch information...
markstory committed Apr 11, 2013
1 parent 5e00fdf commit 8bd1980dd48191ab738a2051c8c1c7bdd29aef3f
Showing with 4 additions and 4 deletions.
  1. +2 −2 lib/Cake/Test/Case/Utility/CakeTimeTest.php
  2. +2 −2 lib/Cake/Utility/CakeTime.php
@@ -846,7 +846,7 @@ public function testFromStringWithDateTime() {
$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 @@ public function testFromStringWithDateTimeNoConversion() {
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 @@ public static function fromString($dateString, $timezone = null) {
) {
$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);
}

0 comments on commit 8bd1980

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