Skip to main content

date Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for the Linux date command covering display formats, format specifiers, relative dates, timezones, Unix timestamps, and setting the system clock.

date is the Linux command for displaying and setting the system date and time. This cheatsheet covers default and custom output formats, the most common format specifiers, relative date strings, timezone overrides, Unix timestamp conversion, and manual clock changes.

Display Date and Time

Print the current date and time in common forms.

CommandDescription
dateCurrent date and time in the default format
date +%FDate in YYYY-MM-DD format
date +%TTime in HH:MM:SS format
date +"%F %T"Date and time combined
date -uCurrent time in UTC
date -RDate in RFC 5322 email format
date --iso-8601=secondsISO 8601 with seconds

Common Format Specifiers

Build custom output with % controls after a +.

SpecifierDescription
%Y %m %dYear, month, day of month
%H %M %SHour (24h), minute, second
%I %pHour (12h), AM/PM
%A %aFull / abbreviated weekday name
%B %bFull / abbreviated month name
%j %uDay of year, day of week (Mon=1)
%F %T %DYYYY-MM-DD, HH:MM:SS, mm/dd/yy
%s %nUnix timestamp, newline

Format Examples

Combine specifiers into ready-to-use strings.

CommandDescription
date +"%Y-%m-%d"2026-06-23
date +"%H:%M:%S"14:31:01
LC_TIME=C date +"%A, %d %B %Y"Tuesday, 23 June 2026
date +"%Y%m%d"Compact stamp for filenames
date +"%Y-%m-%d_%H-%M-%S"Safe timestamp for logs
date +"%Z (%z)"Timezone name and offset

Relative Dates

Use -d (or --date) with a date string.

CommandDescription
date -d "tomorrow"Tomorrow’s date
date -d "yesterday"Yesterday’s date
date -d "monday"Upcoming Monday (today if it is Monday)
date -d "last week"One week ago
date -d "30 days ago"30 days in the past
date -d "2 hours"Two hours from now
date -d "16 Dec 1974" +%AWeekday of a fixed date

Timezones

Override the timezone for one invocation.

CommandDescription
TZ='Asia/Tokyo' dateShow time in another timezone
TZ='UTC' dateShow current UTC time
date -d 'TZ="Australia/Sydney" 09:00 next Mon'Convert a time across zones
date +"%Z"Show the current timezone abbreviation
date +"%z"Show the numeric UTC offset

Unix Timestamps

Convert between epoch seconds and dates.

CommandDescription
date +%sCurrent Unix timestamp
date -d @1234567890Convert a timestamp to a date
date -d @1234567890 +"%F %T"Convert and format a timestamp
date -u -d @0Print the Unix epoch start
date -d "2026-06-23 12:00" +%sConvert a date to a timestamp

Files and Scripts

Read file times and capture the date in scripts.

CommandDescription
date -r /etc/hostsLast modification time of a file
backup-$(date +%F).sqlDate-stamped filename
now=$(date +%s)Store the timestamp in a variable
date +"%F %T" >> log.txtAppend a timestamp to a log
date --debug -d "next fri"Show how a date string is parsed

Set the System Clock

Disable NTP before a manual change, then re-enable it afterward.

CommandDescription
sudo timedatectl set-ntp falseDisable automatic time synchronization
sudo date --set="2026-06-23 17:30"Set the date and time
sudo date --set="17:30"Set the time only
sudo date MMDDhhmmCCYYSet the clock with the legacy positional format
sudo timedatectl set-time '2026-06-23 17:30:00'Preferred way on systemd systems
sudo timedatectl set-ntp trueRe-enable automatic time synchronization

Use these references for deeper date and time tasks.

GuideDescription
date Command in LinuxFull walkthrough of formatting, timezones, and epoch conversion
timedatectl CheatsheetManage system time, timezone, and NTP sync
Set or Change the Time Zone in LinuxChange the system timezone
crontab CheatsheetSchedule time-based jobs