2

I want to set a custom time in ubuntu 14.04

lets say : 8 OCT 2010 18:00:00

wrkstn@wrkstn-VirtualBox:~$ sudo date --set="8 OCT 2006 18:00:00"
Sun Oct  8 18:00:00 PETST 2006
wrkstn@wrkstn-VirtualBox:~$ date
Fri Sep  2 01:21:51 PETT 2016
wrkstn@wrkstn-VirtualBox:~$ 

But i am not able to set custom date with Date command. Please Tell me how can i accomplish this.

7
  • But what is this command line output from then? – grooveplex Sep 1 '16 at 13:31
  • Reproducing this on my 16.04, the time does not change there either this way... I wonder how this is meant to work. – Byte Commander Sep 1 '16 at 13:34
  • 1
    Does this help? – user308164 Sep 1 '16 at 13:35
  • Btw, that question should be migrated here. – user308164 Sep 1 '16 at 13:36
  • 1
    @luchonacho There's no need to migrate that question, Ubuntu is on-topic on Super User as well. And it would be a duplicate of this one (or rather the other way round). – Byte Commander Sep 1 '16 at 13:44
6

If you have set up your computer to automatically synchronize time with an internet time server via NTP (which is the default), you can not edit the system time manually, because ntpd will immediately synchronize it with the internet clock again.

To set the system time and date manually, disable NTP:

sudo timedatectl set-ntp false

Then you can persistently change the time and date, like this:

sudo date -s "2010-1-1 13:00"

If you want automatic internet time synchronization enabled again, run this:

sudo timedatectl set-ntp true
6
  • no, again year is always set to 2016 – Rahul V Sharma Sep 1 '16 at 15:47
  • Not here. What was your exact date string, maybe that one was badly formatted? – Byte Commander Sep 1 '16 at 15:58
  • sudo date -s "2010-1-1 13:00" putting this string – Rahul V Sharma Sep 1 '16 at 16:08
  • This correctly sets the full date, including the year, once NTP is disabled. I can't reproduce your problem. Would you mind just trying aain? – Byte Commander Sep 1 '16 at 16:44
  • 1
    A word of warning. All sorts of unintended consequences will arise if you set your clock way off real time (as in years). Things like expire scripts will start deleting things, calendar notifications for thousands of events you missed will show up. You might want to do this in a vm. – stu Jan 13 '17 at 15:37
0

I am assuming your Ubuntu runs in VirtualBox from your machine name. In this case, VirtualBox manages the guest time and adjusts it to match host time by default. You can disable this behavior using the command:

VBoxManage setextradata "VM name" "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

Source: https://www.virtualbox.org/manual/ch09.html#disabletimesync

1
  • No nothing happened with this command. – Rahul V Sharma Sep 1 '16 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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