Skip to content

Commit

Permalink
Clarify toFormat docs (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-p authored May 18, 2021
1 parent 043f2b9 commit 2d66ce4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/moment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()` | |
Expand Down

0 comments on commit 2d66ce4

Please sign in to comment.