Linux date Command: Display and Format the Current Time

date displays the current date and time and outputs it in the specified format. It is especially useful for creating date strings in automation scripts.

What is the date command?

The default output is affected by the system timezone and locale. If you specify +FORMAT, you can output only the fields you need, and using -u displays it in Coordinated Universal Time (UTC). It also has the ability to actually set the time, but this should be distinguished from regular query operations.

Basic syntax

date [option] [+format]

Installed implementations and options may vary depending on the distribution. Check the current system's description with man date.

Examples

Current date and time

Outputs according to the default locale and timezone.

date

Consistent date format

Displays the date in year-month-day format for filenames or log identifiers.

date +%Y-%m-%d

Check UTC time

Reduces the time zone difference when comparing log times between servers.

date -u +%Y-%m-%dT%H:%M:%SZ

Understanding Display Formats and Time Zones

date can display the current time or change the format. The following command outputs the time in a fixed format based on UTC, but the date and values will vary each time it is run.

date -u '+%Y-%m-%d %H:%M UTC'

Example output:

2026-09-28 00:00 UTC

If you omit -u, the current system time zone setting will be applied. %Y is the four-digit year, %m is the month, and %d is the day. The above date is an example value for explanation and is not a record of setting the actual system time. Changing the system time affects authentication, logs, and scheduled tasks, so distinguish it from simple viewing.

Main Options and Format

Options/Format Description
+%Y-%m-%d Outputs in year-month-day format.
+%H:%M:%S Outputs hour:minute:second.
-u Outputs in UTC.
-I Outputs in ISO 8601 date format.
-d string Interprets and displays the date string specified in GNU date.

Precautions when using

Changing the system time using date -s can affect logs, authentication, and scheduled tasks. Check the time synchronization status before changing the clock. Quoting the format string may be necessary in the shell, and GNU-specific options differ from other Unix environments.

Frequently Asked Questions

Which time zone does the output of date follow?

By default, it follows the system or the time zone specified in the TZ environment variable. Use -u to view it in UTC.

Official Documentation

You can check the exact behavior of the options and implementation differences in the official date documentation.

More in This Category
Linux which Command: Find Executables in PATH

Linux which Command: Find Executables in PATH

Learn how Linux which searches PATH for executables, shows all matching paths, differs from type and command -v, and should be used carefully in scripts.

Linux zip Command: Create ZIP Archives

Linux zip Command: Create ZIP Archives

Learn how to create ZIP Archives with the Linux zip command, including practical examples, key options, and important precautions.

Linux Tutorial / Read Files with cat, less, more, head, and tail

Linux Tutorial / Read Files with cat, less, more, head, and tail

Learn when to use cat, less, more, head, and tail to read Linux files, with a small reproducible example and guidance for long files and logs.

Linux su Command: Switch User Accounts and Login Shells

Linux su Command: Switch User Accounts and Login Shells

Learn how to use the Linux su command to switch user accounts and start login or non-login shells, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux Tutorial / Understand Users, Groups, and File Ownership

Linux Tutorial / Understand Users, Groups, and File Ownership

Understand UIDs, GIDs, primary and supplementary groups, and file ownership, then inspect them safely with id, groups, getent, ls, and stat.

Linux htop Command: Explore Processes Interactively

Linux htop Command: Explore Processes Interactively

Learn how to explore Processes Interactively with the Linux htop command, including practical examples, key options, and important precautions.

A History of Linux: From a 1991 Hobby Project to Global Infrastructure

A History of Linux: From a 1991 Hobby Project to Global Infrastructure

Trace the history of Linux from Unix and the GNU Project through the first Linux kernel, distributions, enterprise adoption, cloud computing, containers, and modern infrastructure.

Linux less Command: Browse and Search Long Text Files

Linux less Command: Browse and Search Long Text Files

Learn how to browse long files with Linux less, move forward and backward, search text, follow growing logs, preserve colors, and exit the pager.

Linux dd Command: Copy and Convert Data by Blocks

Linux dd Command: Copy and Convert Data by Blocks

Learn how to copy and convert files or block devices with Linux dd, choose block sizes and ranges, display progress, verify results, and avoid overwriting the wrong device.

Linux nslookup Command: Query DNS Names and Records

Linux nslookup Command: Query DNS Names and Records

Learn how to query DNS Names and Records with the Linux nslookup command, including practical examples, key options, and important precautions.