Linuxlab

date command in Linux: current date and formats

Updated July 3, 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 UTC

How it works: the format string

An argument that starts with + is a format string: %Y is the year, %m the month, %d the day, %H:%M:%S hours, minutes and seconds. Everything else prints as is, so date +%Y-%m-%d gives 2026-06-26. The system stores time as a count of seconds since 1970 (Unix time), and date only renders it for your timezone.

Used in

You need this in the lesson The command line. The theory is the chapter The command line: first contact.

See also

Anatomy of a command.

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.