format date

For strings.

Format a given date using a format string.

Command Type

built-in

Signature

> format date {flags} (format string)

Flags

  • --list, -l: Lists strftime cheatsheet.

Parameters

  • format string: The desired format date.

Input/output types:

input output
datetime string
string string
nothing table
any table
list<datetime> list<string>
list<string> list<string>

Examples

Format a given date-time using the default format (RFC 2822).

> '2021-10-22 20:00:12 +01:00' | into datetime | format date
Fri, 22 Oct 2021 20:00:12 +0100

Format a given date-time as a string using the default format (RFC 2822).

> "2021-10-22 20:00:12 +01:00" | format date
Fri, 22 Oct 2021 20:00:12 +0100

Format a given date-time according to the RFC 3339 standard.

> '2021-10-22 20:00:12 +01:00' | into datetime | format date "%+"
2021-10-22T20:00:12+01:00

Format the current date-time using a given format string.

> date now | format date "%Y-%m-%d %H:%M:%S"

Format the current date using a given format string.

> date now | format date "%Y-%m-%d %H:%M:%S"

Format a given date using a given format string.

> "2021-10-22 20:00:12 +01:00" | format date "%Y-%m-%d"
2021-10-22

Format a list of date strings using a given format string.

> ["2021-10-22 20:00:12 +01:00", "2021-10-23 20:00:12 +01:00"] | format date "%Y-%m-%d"
╭───┬────────────╮
│ 0 │ 2021-10-22 │
│ 1 │ 2021-10-23 │
╰───┴────────────╯

Format a list of datetimes using a given format string.

> [2021-10-22T20:00:12+01:00, 2021-10-23T20:00:12+01:00] | format date "%Y-%m-%d"
╭───┬────────────╮
│ 0 │ 2021-10-22 │
│ 1 │ 2021-10-23 │
╰───┴────────────╯

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.