I am in a need of manipulating the system time for few minutes.
Say I need to keep the time as it is and change the date to next date.
After few minutes.. I need to go back to the normal time with out giving any manual inputs.
How is this possible with command line only.
I have gone through this What is the command line statement for changing the System clock? and it requires to input date+time.
I dont want to change the time, only the date. Once the requirement is done that is after few minutes, I dont want to enter any manual inputs for date and time..
I want to go back to regular time with command line.
This is an example of what ( I think ) you want. It will change the year only to last year for 4 minutes then back to current date again. Your machine needs to be connected to the Internet for this to work:
For the below to work, you should first go to Settings → Date & Time and disable Automatic Date & Time.
You can then use the following command as a (long) one-liner:
The above command:
Gets the current system time:
and sets the date to the one you wish, keeping the current time:
In this example the date, which you may change to what you need, is
2010-05-02
.Keeps the altered date for the specified time interval using the
sleep
command. Here I have usedsleep 10
to keep the altered time for 10 seconds. You can add anm
,h
, ord
suffix tosleep
's argument (here10
) to specify the time in minutes, hours, or days, respectively.Reverts the time to the current time (requires internet access):
Credits to Shrukul Habib.