Skip to content

Commit 745cef8

Browse files
authored
DateTime: Don't convert when there is no user (#43521)
1 parent fd7d6db commit 745cef8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libraries/src/HTML/HTMLHelper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,10 @@ public static function date($input = 'now', $format = null, $tz = true, $gregori
884884
// Get a date object based on UTC.
885885
$date = Factory::getDate($input, 'UTC');
886886

887-
// Set the correct time zone based on the user configuration.
888-
$date->setTimezone($app->getIdentity()->getTimezone());
887+
// Set the correct time zone based on the user configuration. CLI doesn't have a user
888+
if ($app->getIdentity()) {
889+
$date->setTimezone($app->getIdentity()->getTimezone());
890+
}
889891
} elseif ($tz === false) {
890892
// UTC date converted to server time zone.
891893
// Get a date object based on UTC.

0 commit comments

Comments
 (0)