Date: Difference between revisions
From Leo's Notes
This page was last edited on 30 March 2020, at 20:21.
m Text replacement - "Category:Linux{{Navbox Linux}}" to "{{Navbox Linux}}Category:Linux" |
mNo edit summary |
||
| Line 1: | Line 1: | ||
The {{code|date}} unix utility | The {{code|date}} unix utility can set or show the current time. | ||
== Setting the Time == | |||
You can set the system clock: | |||
{{highlight|lang=terminal|code= | |||
# date -s "Mar 30 2020 13:16" | |||
}} | |||
Though, you really should be using NTP instead. | |||
== Formatting == | == Formatting == | ||
Revision as of 20:21, 30 March 2020
The date unix utility can set or show the current time.
Setting the Time
You can set the system clock:
# date -s "Mar 30 2020 13:16"
Though, you really should be using NTP instead.
Formatting
date can be formatted using the + argument followed by the format string. For example:
# date +"%T"
11:26:25
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) |