diff --git a/tests/system/I18n/TimeTest.php b/tests/system/I18n/TimeTest.php index 75f4416676fc..176af93e70d9 100644 --- a/tests/system/I18n/TimeTest.php +++ b/tests/system/I18n/TimeTest.php @@ -253,6 +253,18 @@ public function testCreateFromTimestamp() $this->assertSame(date('2017-03-18 00:00:00'), $time->toDateTimeString()); } + public function testCreateFromTimestampWithTimezone() + { + // Set the timezone temporarily to UTC to make sure the test timestamp is correct + date_default_timezone_set('UTC'); + + $timestamp = strtotime('2017-03-18 midnight'); // in UTC + + $time = Time::createFromTimestamp($timestamp, 'Asia/Jakarta'); // UTC +7 + + $this->assertSame(date('2017-03-18 07:00:00'), $time->toDateTimeString()); + } + public function testTestNow() { $this->assertFalse(Time::hasTestNow());