From 4eb42e0b05ce49171094fcf59931c3769cbcbaa4 Mon Sep 17 00:00:00 2001 From: bancer Date: Fri, 18 Jan 2019 17:07:05 +0100 Subject: [PATCH] Add unit test for timezone conversion --- lib/Cake/Test/Case/Utility/CakeTimeTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index b358b1b48..3e597154e 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -1226,4 +1226,13 @@ class CakeTimeTest extends CakeTestCase { $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); + } + }