Skip to content

Commit 2d66ce4

Browse files
authored
Clarify toFormat docs (#938)
1 parent 043f2b9 commit 2d66ce4

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

docs/formatting.md

+2
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ DateTime.fromISO('2014-08-06T13:07:04.054')
141141
.toFormat('yyyy LLL dd'); //=> '2014 août 06'
142142
```
143143

144+
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`).
145+
144146
### Escaping
145147

146148
You may escape strings using single quotes:

docs/moment.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ See the [formatting guide](formatting.html) for more about the string-outputting
139139
| full ISO 8601 | `iso()` | `toISO()` | |
140140
| ISO date only | None | `toISODate()` | |
141141
| ISO time only | None | `toISOTime()` | |
142-
| custom format | `format(...)` | `toFormat(...)` | The format tokens differ between Moment and Luxon, such that the same format string cannot be used between the two. |
142+
| 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. |
143143
| RFC 2822 | | `toRFC2822()` | |
144144
| HTTP date string | | `toHTTP()` | |
145145
| JS Date | `toDate()` | `toJSDate()` | |

0 commit comments

Comments
 (0)