You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/pages/api/utils/dates.mdx
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,8 +19,46 @@ Formats a date according to the specified format string and options.
19
19
20
20
> **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.
21
21
22
+
> **Timezone Lookup** You can use [IANA.org's guide](https://www.iana.org/time-zones) to look up supported timezones.
23
+
22
24
> **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.
23
25
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
0 commit comments