Skip to content

Commit

Permalink
DateTime::getTimestamp() is PHP5.3+
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 11, 2013
1 parent 5e00fdf commit 8bd1980
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Utility/CakeTimeTest.php
Expand Up @@ -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);

Expand All @@ -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'));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Utility/CakeTime.php
Expand Up @@ -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);
}
Expand Down

0 comments on commit 8bd1980

Please sign in to comment.