date

date prints the current date and time. With the right option, it can also set the system clock, display some other moment, or format a date however you need.

date [options] [+format]
$ date
Sun 17 May 2026 14:32:08 BST
$ date +%Y-%m-%d
2026-05-17

Formatting the output #

A +format argument controls the output. The format string is printed literally, except for % sequences, each of which is replaced by a piece of the date. The common ones:

SequenceIs replaced by
%Y %m %dYear, month, day.
%H %M %SHour, minute, second.
%FThe full date — same as %Y-%m-%d.
%TThe time — same as %H:%M:%S.
%A %aWeekday name, full and abbreviated.
%B %bMonth name, full and abbreviated.
%jDay of the year.
%sSeconds since 1970-01-01 UTC.
%z %ZNumeric and named time zone.
%%A literal %.

The full set is long; date --help lists every sequence with an example.

Displaying a different moment #

OptionEffect
-d, --date=STRINGShow the time described by STRING"yesterday", "next Friday", "@1615432800" — instead of now.
-r, --reference=FILEShow FILE's last modification time.
-f, --file=DATEFILELike -d, but once for each line of DATEFILE.
-u, --universalWork in Coordinated Universal Time (UTC) rather than the local zone.

Standard formats #

OptionOutput
-I, --iso-8601[=FMT]ISO 8601 — FMT is date, hours, minutes, seconds, or ns.
-R, --rfc-emailThe format used in email headers.
--rfc-3339=FMTRFC 3339 — FMT is date, seconds, or ns.

Setting the clock #

OptionEffect
-s, --set=STRINGSet the system clock to the time described by STRING.

Setting the clock changes state for the whole system, so it is a privileged operation — it succeeds only for a caller whose token carries the right to set the time, and is refused otherwise. See Privileges.

Exit status #

CodeMeaning
0The date was printed or set.
1An invalid date or format, or the clock could not be set.

Edit this page