diff --git a/system/I18n/Time.php b/system/I18n/Time.php index 64b4d350e8fd..dd97815f66cf 100644 --- a/system/I18n/Time.php +++ b/system/I18n/Time.php @@ -82,7 +82,7 @@ public function __construct(?string $time = null, $timezone = null, ?string $loc // If a test instance has been provided, use it instead. if ($time === '' && static::$testNow instanceof self) { $timezone = $timezone ?: static::$testNow->getTimezone(); - $time = (string) static::$testNow->toDateTimeString(); + $time = static::$testNow->format('Y-m-d H:i:s'); } $timezone = $timezone ?: date_default_timezone_get(); diff --git a/tests/system/I18n/TimeTest.php b/tests/system/I18n/TimeTest.php index 03f142479478..7571f66eca99 100644 --- a/tests/system/I18n/TimeTest.php +++ b/tests/system/I18n/TimeTest.php @@ -1058,4 +1058,18 @@ public function testUnserializeTimeObject() $this->assertTrue($time2->equals($time1)); $this->assertNotSame($time1, $time2); } + + public function testSetTestNowWithFaLocale() + { + $currentLocale = Locale::getDefault(); + Locale::setDefault('fa'); + + Time::setTestNow('2017/03/10 12:00', 'Asia/Tokyo'); + + $now = Time::now()->format('c'); + + $this->assertSame('2017-03-10T12:00:00+09:00', $now); + + Locale::setDefault($currentLocale); + } }