The clock timezone command sets system time to your local time zone.
The undo clock timezone command restores system time to Coordinated Universal Time (UTC).
By default, the local time zone is the UTC time.
| Parameter | Description | Value |
|---|---|---|
| time-zone-name | Specifies the name of the time zone. | The value is a string of 1 to 32 case-sensitive characters without spaces. NOTE:
When double quotation marks are used around the string, spaces are allowed in the string. |
| add | Indicates that the time of time-zone-name is equal to the UTC time plus the time offset. That is, the default UTC time plus offset is equal to the time of time-zone-name. | - |
| minus | Indicates that the time of time-zone-name is equal to the UTC time minus the time offset. That is, the default UTC time minus offset is equal to the time of time-zone-name. | - |
| offset | Specifies the difference between time-zone-name time and UTC time. | The format is HH:MM:SS.
|
Usage Scenario
The system clock is the time indicated by the system timestamp. Because the rules governing local time differ in different regions, the system clock can be configured to comply with the rules of any given region.
System clock = UTC + Time zone offset + DST offset
To ensure the normal communication between devices, set an accurate system clock. You can run the clock timezone and clock daylight-saving-time commands to set the time zone and DST offsets, respectively.
Configuration Impact
Follow-up Procedure
After setting the time zone, use the display clock command to check the configuration. The time shown in messages such as logs and debugging information will be the local time in the time zone set, either standard or daylight saving time.
Precautions
# In Beijing China, you can set the local time zone name to BJ.
If the default UTC time is London time and the local time in London is 00:00:00 on January 1, 2009, the method for obtaining the Beijing time is as follows: Beijing is in time zone UTC+8, and the time offset increases by 8. To obtain the expected BJ time zone, add offset 8 to the default UTC time zone.
<sysname> clock datetime 0:0:0 2009-01-01
<sysname> system-view
[sysname] clock timezone BJ add 08:00:00