WackoWiki: IntlDateFormatter

https://wackowiki.org/doc     Version: 79 (03/30/2025 10:46)

IntlDateFormatter



Implement the IntlDateFormatter::format() for our date and time formatting as well let the IntlDateFormatter determine the DST according the chosen timezone.

1. Timezone

Upgrade: Set timezone for all users back to UTC, the user must set his timezone again. The current offset is not unique and the DST depends on the location.

Registration: The Browser's Timezone can be detected via JavaScript, however this is also guesswork. Should we set here UTC as default too?

2. Upgrade

This changes a few things:

2.1. New format syntax

The installer resets your custom settings to the defaults. Change it again via the Admin panel with the new syntax.

config DateTime::format IntlDateFormatter
date_format d.m.Y dd.MM.y
time_format H:i HH:mm
time_format_seconds H:i:s HH:mm:ss

For example you might want set the date_format to dd/MM/y.

ICU Formats
Date Field Symbol Table[link5]

date_format($unix_time, $pattern)	

- the unix time must be passed as UTC time

2.1.1. Local formats


# IntlDateFormatter Example Note
1 dd.MM.y 10.07.1996 bg, cs, de, et, no, pl, ro, ru, uk
2 dd/MM/y 10/07/1996 ar, el, es, fr, it, pt
3 dd-MM-y 10-07-1996 en_gb, hi, en_in, nl
4 y.MM.dd 1996.07.10 hu
5 y-MM-dd 1996-07-10 ISO 8601
6 y/MM/dd 1996-07-10 fa
7 y年MM月dd日 1996年07月10日 ja, zh
8 y년 MM월 dd일 1996년 07월 10일 ko
9 MM/dd/y 07/10/1996 en_us
...

2.2. Timezone

The installer sets the timezone for the system as well as for all users back to UTC as default. Because the timezone DST is determined by the location the users have to set their location in the user settings again, the timezone offset is only an indicator and not unique.

If all of your users work in one place, you can set the timezone via a SQL query:
UPDATE wacko_user_setting SET timezone = 'Pacific/Tahiti' WHERE timezone = 'UTC';

2.3. Installation

Do not forget to delete per hand the config cache and restart your browser before you run the upgrade process, so you get a new session - else it will use your old session after the upgrade and you will get a 500er error, because the 'timezone' must be set 'UTC' in the session.

This change will be available with WackoWiki 6.1.4 release.

2.4. Backwards Compatibility

All of the features are based on the given Locale, so no need for using the system-wide "setlocale" functionality is needed anymore.

However set_language() still uses setlocale() for 3rd party libraries (e.g. SimplePie) and legacy scripts not using intl based date & time formatting.

3. Bug

Shows 31.12.2025 on 31.12.2024
Is this a timezone bug? Report?

4. See also