Skip to content

Commit b193a62

Browse files
committed
fix: Time::toDateTime() loses microseconds
1 parent 6b32d58 commit b193a62

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

system/I18n/TimeTrait.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,11 @@ public static function instance(DateTime $dateTime, ?string $locale = null)
314314
*/
315315
public function toDateTime()
316316
{
317-
$dateTime = new DateTime('', $this->getTimezone());
318-
$dateTime->setTimestamp(parent::getTimestamp());
319-
320-
return $dateTime;
317+
return DateTime::createFromFormat(
318+
'Y-m-d H:i:s.u',
319+
$this->format('Y-m-d H:i:s.u'),
320+
$this->getTimezone()
321+
);
321322
}
322323

323324
// --------------------------------------------------------------------

0 commit comments

Comments
 (0)