The date unix utility can set or show the current time.

Setting the Time[edit | edit source]

You can set the system clock:

# date -s "Mar 30 2020 13:16"

Though, you really should be using NTP instead.

Formatting[edit | edit source]

date can be formatted using the + argument followed by the format string. For example:

# date +"%T"

Here are some common formats.

Format Output
%T 12:34:56 (ie: HH:MM:SS)
%r 09:30:55 PM (ie: HH:MM:SS XX)
%m-%d-%y 12-02-15 (ie: MM:DD:YY)
%m-%d-%Y 12-02-2015 (ie: MM:DD:YYYY)
%D 12/02/2015 (ie: MM/DD/YYYY)