From 2d66ce457b6207321cf3d230ccefbcee990e7e5d Mon Sep 17 00:00:00 2001 From: Andrey Pissantchev Date: Tue, 18 May 2021 19:39:58 +0100 Subject: [PATCH] Clarify toFormat docs (#938) --- docs/formatting.md | 2 ++ docs/moment.md | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/formatting.md b/docs/formatting.md index f9ab1457e..930ab43c9 100644 --- a/docs/formatting.md +++ b/docs/formatting.md @@ -141,6 +141,8 @@ DateTime.fromISO('2014-08-06T13:07:04.054') .toFormat('yyyy LLL dd'); //=> '2014 août 06' ``` +Note `toFormat` defaults to `en-US`. If you need the string to be internationalized, you need to set the locale explicitly like in the example above (or more preferably, use `toLocaleString`). + ### Escaping You may escape strings using single quotes: diff --git a/docs/moment.md b/docs/moment.md index bcee2a858..1078c9d5a 100644 --- a/docs/moment.md +++ b/docs/moment.md @@ -139,7 +139,7 @@ See the [formatting guide](formatting.html) for more about the string-outputting | full ISO 8601 | `iso()` | `toISO()` | | | ISO date only | None | `toISODate()` | | | ISO time only | None | `toISOTime()` | | -| custom format | `format(...)` | `toFormat(...)` | The format tokens differ between Moment and Luxon, such that the same format string cannot be used between the two. | +| custom format | `format(...)` | `toFormat(...)` | The format tokens differ between Moment and Luxon, such that the same format string cannot be used between the two. Note `toFormat` is meant to be used for machine-readable formats. For anything human-readable, you really want to use `toLocaleString()` instead. | | RFC 2822 | | `toRFC2822()` | | | HTTP date string | | `toHTTP()` | | | JS Date | `toDate()` | `toJSDate()` | |