Page 1 of 1

Setting the date and time on a guest to an arbitrary value

Posted: 17. Jan 2011, 02:22
by rossmcm
This question has been asked before, but the solutions given seem somewhat clunky, and I'm wondering if there is a simpler way.

I want to test an app's behaviour during transitions in and out of daylight savings time. I therefore want to be able to set the date and time of a VM, (preferably from the Control Panel applet, but from a batch file is fine) and not have it "corrected" ti the host's time for me.

I see that time synchronization with the host is achieved via the guest additions. I don't want to give up all of those features in order to stop the time being synchronized. There seems to be no way to disable an individual feature of the guest additions, so I'm wondering if I can use the options for tuning --timesync to do this.

E.g. is there come combination of --timesync-interval, --timesync-min-adjust, --timesync-set-start, --timesync-set-on-restore which will allow me to set the date and time to a specific value and then not adjust it ever again (or until a very long time has elapsed)?

Then I can have several batch files that I can run to set to time and date to a series of dates near the daylight transition times.

Help!
TIA
Ross

Re: Setting the date and time on a guest to an arbitrary val

Posted: 14. Nov 2011, 22:01
by rossmcm
Found the answer in elsewhere in this forum. Bearing in mind the problem is not one of being unable to set the date (that's easy), but one of retaining the new date without VB re-sync-ing from the host.

The answer is here: viewtopic.php?t=8535
This can now be done using VBoxManage utility. It's a command-line tool, which is available in the Virtualbox install folder in Windows or in ~/Library/Virtualbox on Mac.

Turn off time syncing:
vboxmanage setextradata [VMname] "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "1"

Turn it back on:
vboxmanage setextradata [VMname] "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "0"

note: [VMname] is the name of your virtual machine.
Worked for me under WinXP. The main problem is that without sync to the host the time drifts - I had 2 XP VMs running overnight and one kept time, the other one lost about 4 hours. Luckily in this application (testing behaviour over day transitions) it's not a big issue.

R