Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify toFormat docs #938

Merged
merged 1 commit into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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