Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there such command for changing the System clock' date and time?

For example:

The current date and time is January 1, 1970 23:30:59:980 where 59 and 980 refers to the seconds and millisecods respectively

And I want to change it to January 2, 1971 24:31:59:990

Is there a command for this?

share|improve this question

3 Answers 3

up vote 13 down vote accepted

To set time in Ubuntu from terminal, you can use the following command:

sudo date new_date_time_string

where new_date_time_string has to follow the format MMDDhhmmyyyy.ss which is described below:

  • MM is a two digit month, between 01 to 12
  • DD is a two digit day, between 01 and 31, with the regular rules for days according to month and year applying
  • hh is two digit hour, using the 24-hour period so it is between 00 and 23
  • mm is two digit minute, between 00 and 59
  • yyyy is the year; it can be two digit or four digit
  • ss is two digit seconds. Notice the period . before the ss.

Source: Manage Time in Ubuntu Through Command Line.

So, in your particular case, you can use:

sudo date 010224311971.59

Or, you can use:

sudo date --set="1971-01-02 24:31:59.990"  && date --rfc-3339=ns

which is exactly what you asked.

Source: http://serverfault.com/a/338395/181186.

share|improve this answer
what is the actual format of the string date? –  Abel Melquiades Callejo Sep 8 '13 at 7:18
does that mean the accuracy can only be limited to seconds? –  Abel Melquiades Callejo Sep 8 '13 at 7:22
@AbelMelquiadesCallejo See my new edits. –  Radu Rădeanu Sep 8 '13 at 7:34

You can use date command to change time and you need sudo permission to do it, an example to set date as 27 June 2014 and time as 1:17 am is :-

sudo date --set "27 Jun 2014 1:17:00"
share|improve this answer
sudo date --set="Mon Feb 16 08:49:56 IST 2015"

That would be correct statement in UBUNTU 14.04.

share|improve this answer
For everyone in the IST timezone only? Does the other answer not work for you? –  Xen2050 Feb 16 at 9:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.