Skip to content

Commit 65e27df

Browse files
committed
Docs: Add info on timezone abbrevs
1 parent 9ffc039 commit 65e27df

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

docs/src/pages/api/helpers/dates.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Date helpers provide utilities for formatting dates and times in templates.
1212
### formatDate
1313
Formats a date according to the specified format string.
1414

15+
> For more information on timezones and usage see [formatDate](/api/utils/dates).
16+
1517
#### Template Syntax
1618
```sui
1719
{formatDate date 'YYYY-MM-DD' (object timezone='UTC')}

docs/src/pages/api/utils/dates.mdx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,46 @@ Formats a date according to the specified format string and options.
1919

2020
> **International Support** This function uses `Intl.DateTimeFormat` internally, please refer to the [associated docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat) for details on timezone and formatting usage.
2121

22+
> **Timezone Lookup** You can use [IANA.org's guide](https://www.iana.org/time-zones) to look up supported timezones.
23+
2224
> **Local Timezone Usage** When the 'local' keyword is used for the timezone option, the function will use the local timezone of the environment where the code is running. This is particularly useful for displaying dates in the user's local time without needing to detect the timezone programmatically.
2325

26+
#### Timezone Shorthand
27+
28+
`formatDate` provides additional shorthand timezones that can be used instead of their city counterparts.
29+
30+
```javascript
31+
const shorthand = reverseKeys({
32+
// North America
33+
'America/New_York': ['ET'],
34+
'America/Chicago': ['CT'],
35+
'America/Denver': ['MT'],
36+
'America/Los_Angeles': ['PT'],
37+
'America/Anchorage': ['AKT'],
38+
'Pacific/Honolulu': ['HT'],
39+
'America/Halifax': ['AT'],
40+
41+
// South America
42+
'America/Sao_Paulo': ['BRT'],
43+
44+
// Europe
45+
'Europe/London': ['UK', 'WET'],
46+
'Europe/Paris': ['CET', 'ECT'],
47+
'Europe/Helsinki': ['EET'],
48+
'Europe/Dublin': ['IRST'], // Note disambiguation with India
49+
50+
// Australia/Oceania
51+
'Australia/Sydney': ['AET'],
52+
'Australia/Adelaide': ['ACT'],
53+
'Australia/Perth': ['AWT'],
54+
'Pacific/Auckland': ['NZT'],
55+
56+
// Asia
57+
'Asia/Kolkata': ['IST', 'INST'], // Note disambiguation with Ireland
58+
'Asia/Tokyo': ['JST'],
59+
'Asia/Singapore': ['SGT']
60+
});
61+
```
2462

2563
#### Parameters
2664

0 commit comments

Comments
 (0)