Add timezone conversion unit test

This commit is contained in:
Val Bancer 2019-01-20 21:54:41 +01:00 committed by GitHub
parent 4eb42e0b05
commit c269ae29e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1235,4 +1235,14 @@ class CakeTimeTest extends CakeTestCase {
$this->assertEquals('2019-01-31 03:00:00', $actual); $this->assertEquals('2019-01-31 03:00:00', $actual);
} }
public function testTimezoneConversionToUTCPlainPHP() {
date_default_timezone_set('Europe/Copenhagen'); // server timezone
$clientTimeZone = new DateTimeZone('Asia/Bangkok');
$clientDateTime = new DateTime('2019-01-31 10:00:00', $clientTimeZone);
// Convert to UTC.
$clientDateTime->setTimezone(new DateTimeZone('UTC'));
$actual = $clientDateTime->format('Y-m-d H:i:s');
$this->assertEquals('2019-01-31 03:00:00', $actual);
}
} }