DATE(1) General Commands Manual DATE(1)

datedisplay date and time

date [-jRu] [-I iso_fmt] [-d datetime | -r epoch] [+format]

date [-jRu] [-I iso_fmt] mmddHHMM[[CC]yy] [+format]

date [-jRu] [-I iso_fmt] -f now_format now [+format]

When date is invoked without arguments it displays the current time Otherwise, depending on the options specified, will print the datetime in a user-defined way.

datetime
Use datetime instead of current time, see DATETIME FORMAT section for more details.
now_format
Use now_format as the strptime(3) format string for now, which will be used instead of the current time.
iso_fmt
Set the ISO-8601 resolution to format at with setting iso_fmt to one of the following values:
d[ate]
date, equivalent to +%Y-%m-%d
h[ours]
hours, equivalent to +%Y-%m-%dT%H%:z
m[inutes]
minutes, equivalent to +%Y-%m-%dT%H:%M%:z
s[econds]
seconds, equivalent to +%Y-%m-%dT%H:%M:%S%:z
n[s]
nano-seconds, equivalent to +%Y-%m-%dT%H:%M:%S,%N%:z
Do no set the system date. This allows to use the -f flag to convert one datetime to another.
Use UTC (coordinated universal time) instead of the local time.
epoch
Use epoch (seconds relative to 1970-01-01 00:00:00 UTC) instead of current time.
Set the default value of format to match RFC5322 (Email / Internet Message Format).
mmddHHMM[[CC]yy]
Sets custom datetime, if -j isn't set, the system time is also set.

Each letters corresponds to:

mm
months aka %m
dd
days aka %d
HH
hours aka %H
MM
minutes aka %M
CC
centuries aka %C
yy
century-less years aka %y

For example 072505542024 corresponds to 2024-07-25T05:54, as you can verify with the following command:

date -j 072505542024 +%Y-%m-%dT%H:%M
format
Set the displayed datetime in strftime(3) format, with additionally %N for nanoseconds and %:z for colon-separated timezone (±ZZ:ZZ).
Otherwise defaults to ‘%c

Multiple different but unambiguous formats are supported: @epoch, Email, asctime, RFC3339.

Leading @ (at) symbol followed by the Unix timestamp (number of seconds before and after 1970-01-01 00:00:00Z), for example ‘@1698791420’ corresponds to 2023-10-31 23:30:20 UTC

Also known as "Internet Message Format" (RFC5322, RFC2822, RFC822), for example:

  • Fri, 21 Nov 1997 09:55:06 -0600
  • 21 Nov 97 09:55:06 GMT

Output format of asctime(3), for example: ‘Sun Sep 16 01:03:52 1973

Profile of ISO 8601:1988, found in modern protocols and file formats. Formatted as ‘YYYY-MM-DDThh:mm:SS[frac][tz]’, where:

YYYY-MM-DD
Corresponds to %Y-%m-%d of strptime(3).
T
Is either ‘T’ or a space.
[frac]
Is either empty, or fractional seconds starting with either a comma (,) or a period (.).
[tz]
When empty it corresponds to local time. Otherwise it can be an UTC offset in the format ‘[+-]HH:?MM’ or the letter "Z", signifying UTC.

Some examples:

  • 2003-06-02T13:37:42.713Z
  • 1971-01-02T03:04:05.678+0900

Look at the manual page of strftime(3) for the environment variables, typical ones are TZ, LC_TIME and LC_ALL but this depends on your system.

The date utility exits 0 on success, and >0 if an error occurs.

clock_settime(3), strftime(3)

date should be compliant with the IEEE Std 1003.1-2024 (“POSIX.1”) specification.

The -d and -R options are present for compatibility with other modern systems such as NetBSD, BusyBox, and GNU coreutils.
The -r option is inspired from BSD and illumos, -f and -j options are inspired by FreeBSD and NetBSD.

The %N and %:z formats are extensions inspired from GNU coreutils.

The -I option was added for compatibility with GNU coreutils, BusyBox, FreeBSD 12.0+.

The -R, -d, -f, -j, and -r options were present in utils-std 0.0.1. The -I option and %N and %:z formats were added in utils-std 0.0.2.

Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>

April 6, 2025 Linux