LinuxCommandLibrary

date

Display current date and time

TLDR

Display the current date using the default locale's format

$ date +%c
copy

Display the current date in UTC, using the ISO 8601 format
$ date [[-u|--utc]] +%Y-%m-%dT%H:%M:%S%Z
copy

Display the current date as a Unix timestamp (seconds since the Unix epoch)
$ date +%s
copy

Convert a date specified as a Unix timestamp to the default format
$ date [[-d|--date]] @[1473305798]
copy

Convert a given date to the Unix timestamp format
$ date [[-d|--date]] "[2018-09-01 00:00]" +%s [[-u|--utc]]
copy

Display the current date using the RFC-3339 format (YYYY-MM-DD hh:mm:ss TZ)
$ date --rfc-3339 s
copy

Set the current date using the format MMDDhhmmYYYY.ss (YYYY and .ss are optional)
$ date [093023592021.59]
copy

Display the current ISO week number
$ date +%V
copy

SYNOPSIS

date [OPTION]... [+FORMAT]
date [--date=STRING | -d STRING] [+FORMAT]
date [-u | --utc | --universal] [MMDDhhmm[[CC]YY][.ss]]

PARAMETERS

-d, --date=STRING
    Display time described by STRING, not 'now'

-f, --file=DATEFILE
    Process dates in DATEFILE, one per line

--iso-8601[=OUTPUT_FORMAT]
    Output in ISO 8601 format (@, seconds, hours, or full)

--reference=FILE
    Use FILE's last modification time instead of current time

-R, --rfc-email, --rfc-822
    Output RFC 5322-compliant date

--rfc-3339=FMT
    Output RFC 3339 date (date, seconds, or ns)

-s, --set=STRING
    Set time from STRING (requires root)

-u, --utc, --universal
    Use UTC for display or set

+FORMAT
    Custom output format with % specifiers

--help
    Display help and exit

--version
    Output version info and exit

DESCRIPTION

The date command is a versatile Linux utility for viewing, formatting, and modifying the system date and time. It prints the current date/time by default in the locale's standard format. Use the +FORMAT specifier for custom output, such as date +%Y-%m-%d for YYYY-MM-DD or date +%H:%M:%S for time only. Format directives like %Y (year), %m (month), %d (day), %H (hour 00-23) enable precise control.

To parse and display dates from strings, use --date or -d, supporting natural language like date -d 'tomorrow 3pm' or relative times like '2 weeks ago'. Setting the system clock requires root privileges via -s or positional arguments like date 010112302023 (Jan 1, 13:30, 2023).

Options handle UTC (-u or --utc), RFC/ISO standards, file timestamps (--reference), and more. Essential for scripts, logs, backups, and cron jobs, date ensures time-aware automation across Unix-like systems.

CAVEATS

Setting date/time requires root privileges.
Output formats depend on LC_TIME locale.
Hardware clock sync needs hwclock; use timedatectl on systemd.

KEY FORMAT SPECIFIERS

%Y full year, %m month (01-12), %d day (01-31), %H hour (00-23), %M minute, %S second, %a weekday abbr, %Z timezone.
Escape with %%.

EXAMPLES

date → current date/time
date +%F %T → 2023-10-05 14:30:00
date -d 'next Friday' → upcoming Friday
sudo date -s '2023-10-05 14:30:00' → set time

HISTORY

Originated in Version 7 Unix (1979) by AT&T Bell Labs. GNU coreutils version since 1990s adds parsing, ISO/RFC support, enhancing portability and scripting.

SEE ALSO

hwclock(8), timedatectl(1), cal(1), zdump(8)

Copied to clipboard