Home  >  Article  >  Operation and Maintenance  >  How to view and modify time in Linux environment?

How to view and modify time in Linux environment?

青灯夜游
青灯夜游forward
2018-10-25 17:08:553149browse

What this article brings to you is to introduce the method of viewing and modifying time in the Linux environment. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

1. Check the date and time

date

2. Check the time zone

date -R

3. Check the UTC time

date -u

4. Modification date

[root@centos ~]# date -s 20181230   /*显示为:Sun Dec 30 00:00:00 EST 2018 */

The modification format is: year, month, day

Note: After modification, the time will become 0 o'clock

5. Modify time

[root@centos ~]# date -s 0815     /* 显示为:Sun Dec 30 08:15:00 EST 2018 */

Modify the format to: hour, minute

6.Modify date and time

[root@centos ~]# date 1230081518   /* 显示为:Sun Dec 30 08:15:00 EST 2018 */

Modify the format to: : Month, day, hour, minute, year

7. When entering two digits for the year, the default is the 21st century. You can also enter the complete year

[root@centos ~]# date 123008152018   /* 显示为:Sun Dec 30 08:15:00 EST 2018 */

8. Also You can ignore the year

[root@centos ~]# date 1230081520    /* 显示为:Sun Dec 30 08:15:00 EST 2018 */

9. If you need to modify the seconds, you can add it to the end and separate it with dots

[root@centos ~]# date 123008152018.20    /* 显示为:Sun Dec 30 08:15:20 EST 2018 */

10. Check the hardware time

[root@centos ~]# hwclock     /* 显示为:Thu 11 Oct 2018 09:32:03 PM EDT  -1.047765 seconds */

11. Synchronize the hardware time to the system

hwclock --hctosys

12. Synchronize the system time to the hardware

hwclock --systohc

The above is the detailed content of How to view and modify time in Linux environment?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete