Skip to content

Commit

Permalink
Update Time.php
Browse files Browse the repository at this point in the history
previously not updating date even though time zone has been set
  • Loading branch information
Toto Prayogo committed Jan 17, 2022
1 parent d61ff23 commit 7602cb4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion system/I18n/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,10 @@ public static function createFromFormat($format, $datetime, $timezone = null)
*/
public static function createFromTimestamp(int $timestamp, $timezone = null, ?string $locale = null)
{
return new self(gmdate('Y-m-d H:i:s', $timestamp), $timezone ?? 'UTC', $locale);
$timezone ??= 'UTC';
$date = new DateTime('now', new DateTimeZone($timezone));

return new self($date->setTimestamp($timestamp)->format('Y-m-d H:i:s'), $timezone, $locale);
}

/**
Expand Down

0 comments on commit 7602cb4

Please sign in to comment.