date Cheatsheet
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.
| Command | Description |
|---|---|
date | Current date and time in the default format |
date +%F | Date in YYYY-MM-DD format |
date +%T | Time in HH:MM:SS format |
date +"%F %T" | Date and time combined |
date -u | Current time in UTC |
date -R | Date in RFC 5322 email format |
date --iso-8601=seconds | ISO 8601 with seconds |
Common Format Specifiers
Build custom output with % controls after a +.
| Specifier | Description |
|---|---|
%Y %m %d | Year, month, day of month |
%H %M %S | Hour (24h), minute, second |
%I %p | Hour (12h), AM/PM |
%A %a | Full / abbreviated weekday name |
%B %b | Full / abbreviated month name |
%j %u | Day of year, day of week (Mon=1) |
%F %T %D | YYYY-MM-DD, HH:MM:SS, mm/dd/yy |
%s %n | Unix timestamp, newline |
Format Examples
Combine specifiers into ready-to-use strings.
| Command | Description |
|---|---|
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.
| Command | Description |
|---|---|
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" +%A | Weekday of a fixed date |
Timezones
Override the timezone for one invocation.
| Command | Description |
|---|---|
TZ='Asia/Tokyo' date | Show time in another timezone |
TZ='UTC' date | Show 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.
| Command | Description |
|---|---|
date +%s | Current Unix timestamp |
date -d @1234567890 | Convert a timestamp to a date |
date -d @1234567890 +"%F %T" | Convert and format a timestamp |
date -u -d @0 | Print the Unix epoch start |
date -d "2026-06-23 12:00" +%s | Convert a date to a timestamp |
Files and Scripts
Read file times and capture the date in scripts.
| Command | Description |
|---|---|
date -r /etc/hosts | Last modification time of a file |
backup-$(date +%F).sql | Date-stamped filename |
now=$(date +%s) | Store the timestamp in a variable |
date +"%F %T" >> log.txt | Append 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.
| Command | Description |
|---|---|
sudo timedatectl set-ntp false | Disable 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 MMDDhhmmCCYY | Set 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 true | Re-enable automatic time synchronization |
Related Guides
Use these references for deeper date and time tasks.
| Guide | Description |
|---|---|
date Command in Linux | Full walkthrough of formatting, timezones, and epoch conversion |
timedatectl Cheatsheet | Manage system time, timezone, and NTP sync |
Set or Change the Time Zone in Linux | Change the system timezone |
crontab Cheatsheet | Schedule time-based jobs |