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
- Allow to override the time zone per invocation
- Docs: Mention capability to reference formats by name, specify custom anchors, more compact formatting in example
- Bump sizes
Copy file name to clipboardexpand all lines: docs/pages/docs/usage/dates-times.mdx
+19-8
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ import PartnerContentLink from 'components/PartnerContentLink';
5
5
6
6
The formatting of dates and times varies greatly between locales (e.g. "Apr 24, 2023" in `en-US` vs. "24 квіт. 2023 р." in `uk-UA`). By using the formatting capabilities of `next-intl`, you can handle i18n differences in your Next.js app automatically.
7
7
8
-
## Formatting dates and times
8
+
## Formatting dates and times[#dates-times]
9
9
10
10
You can format plain dates that are not part of a message with the `dateTime` function that is returned from the `useFormatter` hook:
11
11
@@ -30,6 +30,12 @@ function Component() {
30
30
31
31
See [the MDN docs about `DateTimeFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat#Using_options) to learn more about the options that you can provide to the `dateTime` function or [try the interactive explorer for `Intl.DateTimeFormat`](https://www.intl-explorer.com/DateTimeFormat).
32
32
33
+
If you have [global formats](/docs/usage/configuration#formats) configured, you can reference them by passing a name as the second argument:
34
+
35
+
```js
36
+
format.dateTime(dateTime, 'short');
37
+
```
38
+
33
39
<details>
34
40
<summary>How can I parse dates or manipulate them?</summary>
Copy file name to clipboardexpand all lines: docs/pages/docs/usage/numbers.mdx
+6
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,12 @@ function Component() {
28
28
29
29
See [the MDN docs about `NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat#Using_options) to learn more about the options you can pass to the `number` function or [try the interactive explorer for `Intl.NumberFormat`](https://www.intl-explorer.com/NumberFormat).
30
30
31
+
If you have [global formats](/docs/usage/configuration#formats) configured, you can reference them by passing a name as the second argument:
32
+
33
+
```js
34
+
format.number(499.9, 'precise');
35
+
```
36
+
31
37
## Numbers within messages
32
38
33
39
Numbers can be embedded within messages by using the ICU syntax.
? `The \`timeZone\` parameter wasn't provided and there is no global default configured. Consider adding a global default to avoid markup mismatches caused by environment differences. Learn more: https://next-intl-docs.vercel.app/docs/configuration#time-zone`
? `The \`timeZone\` parameter wasn't provided and there is no global default configured. Consider adding a global default to avoid markup mismatches caused by environment differences. Learn more: https://next-intl-docs.vercel.app/docs/configuration#time-zone`
91
+
: undefined
92
+
)
93
+
);
94
+
}
93
95
}
96
+
94
97
returnoptions;
95
98
}
99
+
96
100
functionresolveFormatOrOptions<Options>(
97
101
typeFormats: Record<string,Options>|undefined,
98
102
formatOrOptions?: string|Options
@@ -153,8 +157,7 @@ export default function createFormatter({
0 commit comments