date command in Linux: current date and formats
Updated November 1, 2026
The date command shows the current date and time and can format them.
Syntax
date [+FORMAT]Common cases
date # the full date and time
date +%Y # the year only, four digits
date +%Y-%m-%d # year-month-day
date -u # the time in UTCSample output
$ date
Sun Jul 26 12:10:30 UTC 2026
$ date +%Y-%m-%d
2026-07-26
$ date "+%Y-%m-%d %H:%M"
2026-07-26 12:10
$ date +%s
1785067830How it works: the format string
An argument that starts with
+is a format string:%Yis the year,%mthe month,%dthe day,%H:%M:%Shours, minutes and seconds. Everything else prints as is, sodate +%Y-%m-%dgives2026-06-26. The system stores time as a count of seconds since 1970 (Unix time), anddateonly renders it for your timezone.
Common mistakes
A format string starts with +. Without the plus, date takes the argument for a date you are giving it and answers date: invalid date with that argument quoted. Compare: date %Y is an error, date +%Y is the year.
A space splits the format into two arguments. date +%Y-%m-%d %H:%M prints date: extra operand and points you at date --help, because %H:%M became a second argument. Quote the whole format, plus sign included: date "+%Y-%m-%d %H:%M".
%m is the month, %M is minutes, and the wrong case raises no complaint. date -d "2026-03-15 09:41:00" +%Y-%M-%d prints 2026-41-15: minutes sit where the month belongs. A file named with such a date looks plausible right up to the moment you try to sort those files by date.
Used in
You need this in the lesson The command line. The theory is the chapter The command line: first contact.
See also
Try it
Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.