From c269ae29e6074911d03473e50bcfe33319f622f1 Mon Sep 17 00:00:00 2001 From: Val Bancer Date: Sun, 20 Jan 2019 21:54:41 +0100 Subject: [PATCH] Add timezone conversion unit test --- lib/Cake/Test/Case/Utility/CakeTimeTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index 3e597154e..a18e38070 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -1235,4 +1235,14 @@ class CakeTimeTest extends CakeTestCase { $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); + } + }