Home Explore Blog CI



nushell

1st chunk of `commands/docs/format_date.md`
05f9928282e6c31d8cd230a84bd6da29b0b9111f4bbafe69000000010000067f
---
title: format date
categories: |
  strings
version: 0.104.0
strings: |
  Format a given date using a format string.
usage: |
  Format a given date using a format string.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `format date` for [strings](/commands/categories/strings.md)

<div class='command-title'>Format a given date using a format string.</div>

## Signature

```> format date {flags} (format string)```

## Flags

 -  `--list, -l`: lists strftime cheatsheet

## Parameters

 -  `format string`: The desired format date.


## Input/output types:

| input    | output |
| -------- | ------ |
| any      | table  |
| datetime | string |
| nothing  | table  |
| string   | string |
## Examples

Format a given date-time using the default format (RFC 2822).
```nu
> '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).
```nu
> "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.
```nu
> '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.
```nu
> date now | format date "%Y-%m-%d %H:%M:%S"

```

Format the current date using a given format string.
```nu
> date now | format date "%Y-%m-%d %H:%M:%S"

```

Format a given date using a given format string.
```nu
> "2021-10-22 20:00:12 +01:00" | format date "%Y-%m-%d"
2021-10-22
```

Title: format date command
Summary
The `format date` command in Nushell formats a date using a provided format string. It accepts datetime or string inputs and outputs a string. It has a flag to list strftime cheatsheet. Examples include formatting dates using default formats, RFC 3339, and custom format strings.