diff options
| author | winter | 2025-03-15 18:35:59 +0000 |
|---|---|---|
| committer | winter | 2025-03-15 18:52:54 +0000 |
| commit | 61b122e88cc6783b4d0cf5142a22002f8e558c60 (patch) | |
| tree | 847b864a93f716157456891d4526077e5f0b93f7 /misc/format_datetime.php | |
| parent | cb904ef3fb05ab106d5e5e12f6273b8117db4216 (diff) | |
implement pages
Diffstat (limited to 'misc/format_datetime.php')
| -rw-r--r-- | misc/format_datetime.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/misc/format_datetime.php b/misc/format_datetime.php index 1a4db52..96ca3a2 100644 --- a/misc/format_datetime.php +++ b/misc/format_datetime.php @@ -1,5 +1,8 @@ <?php +use Digitigrade\Model\UserAccount; +use Digitigrade\UserSettings; + function format_datetime( DateTimeInterface $dt, DateTimeZone|IntlTimeZone|string|null $tz = null @@ -9,6 +12,9 @@ function format_datetime( IntlDateFormatter::RELATIVE_MEDIUM, IntlDateFormatter::SHORT ); - $formatter->setTimeZone($tz ?? $dt->getTimezone()); + static $user = UserAccount::findByCurrentSession(); + static $prefs = $user == null ? null : new UserSettings($user); + + $formatter->setTimeZone($tz ?? $prefs?->get('locale.timezone') ?? $dt->getTimezone()); return $formatter->format($dt); }
\ No newline at end of file |
