mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Add unit test for timezone conversion
This commit is contained in:
parent
73de35c119
commit
4eb42e0b05
1 changed files with 9 additions and 0 deletions
|
@ -1226,4 +1226,13 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
$this->assertEquals($expected->format('Y-m-d H:i'), $converted);
|
$this->assertEquals($expected->format('Y-m-d H:i'), $converted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testTimezoneConversionToUTC() {
|
||||||
|
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.
|
||||||
|
$actual = CakeTime::format($clientDateTime, '%Y-%m-%d %H:%M:%S', false, 'UTC');
|
||||||
|
$this->assertEquals('2019-01-31 03:00:00', $actual);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue