34. System Context - Time
Contents
Linux provides commands that allow you to view system’s time information, and with these commands, you can quickly get the time related information.
System Time
We can use the date command to get or set the time of the system:
|
|

Outputs system's datetime
Timezone
We can use the TZ variable to specify the time zone where our server is located:
|
|

Changes timezone to Pacific Auckland
Time in Difference Timezone
Shows the time in Shanghai when a Auckland clock shows 8:07 on March 07, 2019:
|
|

Changes timezone to China Shanghai and shows the corresponding time in Shanghai
Hour - 24-hour format
|
|

Outputs current hour in 24 hours format
Hour - 24-hour space padded format
|
|

Outputs current hour in 24 hours space padded format
Hour - 12-hour format
|
|

Outputs current hour in 12 hours format
Hour - 12-hour space padded format
|
|

Outputs current hour in 12 hours space padded format
Minute
|
|

Outputs current minutes
Second
|
|

Outputs current seconds
Nanosecond
|
|

Outputs current nanoseconds
Seconds Since Epoch (Timestamp)
|
|

Outputs current timestamp
Time - 24-hour format (Hour:Minute:Second)
|
|

Outputs hour, minute, second in 24-hour time
Time - 24-hour format (Hour:Minute)
|
|

Outputs hour, minute in 24-hour time
Locale Time - 24-hour Clock Time
|
|

Outputs 24-hour clock time
Locale Time - 12-hour Clock Time
|
|

Outputs 12-hour clock time
AM or PM - Uppercase
|
|

Outputs a.m. or p.m. in uppercase
AM or PM - Lowercase
|
|

Outputs a.m. or p.m. in lowercase
Timezone - Four Digits
|
|

Outputs four digits timezone
Timezone - Nearest Minute
|
|

Outputs timezone in nearest minute
Timezone - Nearest Second
|
|

Outputs timezone in nearest second
Timezone - Minimum Necessary Precision
|
|

Outputs the minimum necessary part of the timezone
Timezone - Alphabetic Abbreviation
|
|

Outputs the timezone in alphabetic abbreviation
References 21 System context, 21.1 date: Print or set system date and time, TWiki.org Service: Date and Time Gateway, 29.10 Specifying time zone rules
Author Dong Chen
LastMod Thu Mar 7 2019