< Home

clock datetime

Function

The clock datetime command sets the current date and time on a switch.

Format

clock datetime HH:MM:SS YYYY-MM-DD

Parameters

Parameter Description Value
HH:MM:SS Specifies the current time on a switch. HH specifies the hour, which is an integer ranging from 0 to 23. MM specifies the minute, which is an integer ranging from 0 to 59. SS specifies the second, which is an integer ranging from 0 to 59.
YYYY-MM-DD Specifies the current date (year, month, and day) on the switch. YYYY specifies the year, which is an integer ranging from 2000 to 2037. MM specifies the month, which is an integer ranging from 1 to 12. DD specifies the day, which is an integer ranging from 1 to 31.

Views

User view

Default Level

3: Management level

Usage Guidelines

Usage Scenario

In the scenario where accurate absolute time is required, the current date and time must be set on a switch.

Prerequisite

The time zone and daylight saving time have been configured using the clock timezone and clock daylight-saving-time commands. If the time zone and daylight saving time are not configured, the clock datetime command sets a UTC time.

Precautions

  • The specified time must be in 24-hour format. If you do not specify MM and SS, their values are 0. You must enter at least one digit to specify HH. For example, when you enter 0, the time is 00:00:00.

  • The specified year must be a four-digit number and the specified month and day can be a one-digit number. For example, when you enter 2012-9-1, the time is 2012-09-01.

  • If the device is configured to restart at a specified time and if the system time is changed to be more than 10 minutes later than the specified restart time, the scheduled restart function will be disabled.

The valid time range is based on the UTC, and this command sets the local time. If the DST or time zone is specified in the current environment, the system automatically converts the local time to the UTC.

For example, if you set the time zone to GMT+8 and the local date to 2000-1-1, the UTC converted equals to the local date minus eight hours, which is 1999-12-31. However, the valid date range is 2000 to 2099. As a result, the validity check fails, and date setting fails.

Example

# Set the current time and date of the system to 0:0:0 2012-01-01.

<HUAWEI> clock datetime 0:0:0 2012-01-01
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >