84

When I go to change the date and time it doesn't work. I try to unlock but it just won't unlock. If there is any way to make it work please help.

I know it isn't very descriptive but I really would appreciate some answers.

1

7 Answers 7

94

From man date

-s, --set=STRING
          set time described by STRING

To change date, use the command in terminal,

sudo date --set=STRING

For example, to change date to 25 Sep 2013 15:00, the command would be,

sudo date --set "25 Sep 2013 15:00:00"
10
  • Does it also work if system is rebooted or it has to be apply every time after reboot?
    – user25165
    Apr 30, 2014 at 3:20
  • 1
    Yes, it works after system reboot; you wouldn't have to apply it every time.
    – kern
    May 1, 2014 at 5:35
  • 5
    This appears to no longer work. Using Ubuntu 16.04
    – Teekin
    May 30, 2017 at 15:06
  • 1
    On 16.04 LTS, in Time & Date (System Settings), set the time manually. If not, the command is executed, but the date and the time are not changed. Aug 21, 2018 at 13:06
  • 1
    not working. set date by sudo date --set=STRING result printed that date has changed but actually date is not changed.
    – Igor
    Nov 19, 2021 at 18:06
74

Try this:

sudo dpkg-reconfigure tzdata

This both lets you configure your timezone (you may just pick the same), and automagically synchronizes your time.

If there's no tzdata package, install it:

sudo apt-get update
sudo apt-get install tzdata
1
  • 3
    This solve my Ubuntu server timezone setting, thank you. Dec 20, 2016 at 6:21
16

In 12.04 I don't have to Unlock anything. Just click on the clock on the top bar, and choose Time & Date Settings, once the Time & Date window opens, choose Manually, so you can change the time and date manually; otherwise choose your time zone from the map, and choose Automatic.

enter image description here

enter image description here

5
  • 4
    I am not able to change my system's time this way. I can change the time from the settings but it is not reflecting on my top bar.
    – roopunk
    Jun 26, 2014 at 10:50
  • 1
    It takes a while (+30 secs), but the top bar does update after sometime. (Ubuntu 14.04)
    – shxfee
    Oct 25, 2014 at 19:37
  • You'll have to change the focus of the Date spinner control to have the date changed immediately. Very odd :) (Ubuntu 14.10) Mar 2, 2015 at 14:03
  • 1
    None of these solutions work for me, am on 14.04 as well.
    – Tass
    May 27, 2015 at 17:25
  • sometimes to reflect the settings changes you need to kill unity panel service and restart it. Click clock on the top bar, and choose Time & Date Settings once the Time & Date window opens choose Manually so you can change the time and date manually; otherwise choose your time zone from the map, and choose Automatically. Now to reflect changes instantly open terminal and type killall unity-panel-service Aug 20, 2015 at 22:58
7

See this blog post for setting the date with a machine-friendly format string:

sudo date 120622432007.55

for December 6, 2007, 22:43:55,

and see this answer for setting the date with a human-friendly string:

sudo date --set "15 MAY 2011 1:40 PM"
1
  • Thank you :) That is what I was looking for.
    – Soren
    May 2, 2021 at 9:15
7

If you want to change the time zone only, refer to this:

Therefore

  1. Check Current Timezone Settings: $ timedatectl
  2. Show all Available Timezones: $ timedatectl list-timezones
  3. Change Timezone: $ sudo timedatectl set-timezone Europe/Berlin.
0

To change the date and time to a fixed value on an Ubuntu version using timesyncd, do the following.

Stop timesyncd:

sudo systemctl stop systemd-timesyncd

Set the date and/or time manually:

sudo timedatectl set-time 'YYYY-MM-DD'

Or:

sudo timedatectl set-time 'YYYY-MM-DD HH:MM:SS'

When you want to revert to the current time and date, run:

sudo systemctl start systemd-timesyncd
-2

I had similar issue on my install and the above command gave this error:

date: the argument '19 Sep 2014 20:11:00' lacks a leading '+';
when using an option to specify date(s), any non-option
argument must be a format string beginning with '+'
Try 'date --help'

Help shows -

Usage: date [option]...  [+FORMAT] - (etc)

Added the required plus as indicated to render +19 Sep 2014 20:11:00 which worked.

1
  • This is for displaying the date, not setting it.
    – Adam Katz
    Oct 24, 2018 at 0:43

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