Using virtual box is it possible to set your virtual machine time to be different from host time

Using virtual box is it possible to set your virtual machine time to be different from host time. Say 1 year into the past.

If I wanted to run the windows XP images provided by Microsoft from here.
http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11575

It is noted for the XP image that:

Expires: This image will shutdown and become completely unusable on February 14, 2013.

It is one of the better ways to test IE 6, and IE 7. Other XP typical tests.


Solution 1:

It's no problem at all. Just remember to disable the time synchronisation in the VirtualBox Guest Additions, then set the date+time in the virtual machine as you like. There is also an option to go into the Virtual BIOS and set the date+time there, if that's needed at install time.

This command disables the synchronization:
http://www.virtualbox.org/manual/ch09.html#disabletimesync

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

The following option allows to set an offset in milliseconds: http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm

VBoxManage modifyvm "VM name" --biossystemtimeoffset <msec>

Solution 2:

Example of a windows powerShell script

startVM.ps1

# Starts the VM always on the date 12/30/2016

$tempo = ""+([datetime]"12/30/2016" - [datetime]::Now).TotalMilliseconds
$tempo = ""+[math]::Round($tempo)
$nome = "virtualMachineName"

& ${env:ProgramFiles}\Oracle\VirtualBox\VBoxManage setextradata $nome "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 1

& ${env:ProgramFiles}\Oracle\VirtualBox\VBoxManage modifyvm $nome --biossystemtimeoffset $tempo

& ${env:ProgramFiles}\Oracle\VirtualBox\VBoxManage startvm $nome