Unix - Commandes - date
3.2.2. Changing the Current Time
To change the current time, run the
date
command with the --set
or -s
option as root
:date
--set
HH:MM:SS
Replace HH with an hour, MM with a minute, and SS with a second, all typed in two-digit form.
To change the current time to 11:26 p.m., run the following command as
root
:~]# date --set 23:26:00
3.2.3. Changing the Current Date
To change the current date, run the
date
command with the --set
or -s
option as root
:date
--set
YYYY-MM-DD
Replace YYYY with a four-digit year, MM with a two-digit month, and DD with a two-digit day of the month.
Note that changing the date without specifying the current time results in setting the time to 00:00:00.
Example 3.8. Changing the Current Date
To change the current date to 2 June 2017 and keep the current time (11:26 p.m.), run the following command as
root
:~]# date --set "2017-06-02 23:26:00"
Source :