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 Directory Structure Explained: Purpose of Major Directories

Linux Directory Structure Explained: Purpose of Major Directories

Understand the purpose of major Linux directories such as /etc, /var, /usr, /home, /proc, and /sys, and learn where common system files belong.

Linux apt-get Command: Run APT Package Operations in Scripts

Linux apt-get Command: Run APT Package Operations in Scripts

Learn how to run APT Package Operations in Scripts with the Linux apt-get command, including practical examples, key options, and important precautions.

Linux Tutorial / Manage Files and Directories: Create, Copy, Move, and Delete

Linux Tutorial / Manage Files and Directories: Create, Copy, Move, and Delete

Practice creating, copying, renaming, moving, and deleting files and directories in a dedicated folder while checking each result safely.

Linux dnf Command: Manage RPM Distribution Packages

Linux dnf Command: Manage RPM Distribution Packages

Learn how to manage RPM Distribution Packages with the Linux dnf command, including practical examples, key options, and important precautions.

Linux alias Command: Create Command Shortcuts

Linux alias Command: Create Command Shortcuts

Learn how to use the Linux alias command to create, inspect, and make shell command aliases persistent, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux tail Command: View the End of a File and Follow Logs

Linux tail Command: View the End of a File and Follow Logs

Learn how to use the Linux tail command to view the last lines of a file and follow log updates in real time, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux umount Command: Unmount a Filesystem Safely

Linux umount Command: Unmount a Filesystem Safely

Learn how to unmount a Filesystem Safely with the Linux umount command, including practical examples, key options, and important precautions.

Linux rm Command: Remove Files and Directories Safely

Linux rm Command: Remove Files and Directories Safely

Learn how to remove files and directory trees with Linux rm, use interactive safeguards, limit recursive deletion, and avoid destructive path mistakes.

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.

How to Check IP Addresses on Linux

How to Check IP Addresses on Linux

Learn how to check private and public IP addresses on Linux, identify the active interface and route, and distinguish IPv4, IPv6, and externally visible addresses.