MIAP Digital Literacy Command Line Guide

Learn about BASH commands!

View on GitHub

The date command

Summary

The date command sets and shows the system date and time.

Basic command structure

For all descriptions below, the dollar sign indicates that BASH command prompt.

$ date [options] [+format]

Note: If no option or format is given then the ‘date’ command will print the current locale’s date and time.

Possible Flags

-d

The -d flag displays the given date/time string. The date displayed can be given as a word: today, yesterday, etc. or as a phrase: “Jan 12 2012” Screenshot 2025-11-18 at 8 53 05 PM

-r

The -r flag displays the time when a specified file was last modified. Use the filename or path/to/filename. Screenshot 2025-11-18 at 9 09 09 PM

-s

The -s flag sets the system date and time. That being so, it also requires superuser privileges. Use “YYYY-MM-dd HH:MM:SS”

-u

The -u flag shows the date/time in UTC instead of the local timezone.

Output options

The date command has many different kinds of outputs as described below:

Examples

Go back to the main list of commands