Following examples described using CentOS
Print the current date and time
[root@CentOs ~]# date
Print the current time in 24-hour format
[root@CentOs ~]# date +%R
Print the current time in 12-hour format
[root@CentOs ~]# date +%r
Print last modification time file of FILE
[root@CentOs ~]# date -r <FILE NAME>
in following example used the file called "Test.file"
[root@CentOs ~]# date -r Test.file
Change system date and time from command line
Change date only (Without date format)
[root@CentOs ~]# date -s "2018-08-19"
Change date only (With date format)
[root@CentOs ~]# date +%Y%m%d -s "20180825"
Remember if system date changed without providing time, system time will reset to 00:00:00
Change both date and time
[root@CentOs ~]# date -s "24 aug 2018 20:00:00"
Tech info |
Comments
Post a Comment