44 Votes

VirtualBox: Change Date and Time

Tutorial by Stefan Trost | Last update on 2021-05-12 | Created on 2014-11-02

If you want to change the time in a guest system in VirtualBox, by default, you can experience the following behavior: After changing the clock of an operating system that was launched from VirtualBox, it does not take long before the time is returning to its original state. It seems as if there is no chance to change the time.

This is due to the automatic time synchronization with the host system. That is, there is always used the host computer's time for the virtual machine. But what can you do if you want to run the virtual machine with a different time? We have two options:

Change Settings via Configuration File

Each virtual machine has two configuration files in which the settings for this machine are specified. You can find the files in the folder in which you have stored the virtual machine and the image of the hard disk.

The easiest way to find the folder is to right-click on the virtual machine in question in VirtualBox in the list on the left side of the main window and then select "Show in Explorer" from the context menu (you can also use the menu "Machine" > "Show in Explorer" when a virtual machine is selected.

For example, the path to the folder can be "C:\Users\<User Name>\VirtualBox VMs\<Name of the Virtual Machine>", "C:\Documents and Settings\<User Name>\.VirtualBox\Machines\", "C:\Users\<User Name>\.VirtualBox\Machines\<Name of the Virtual Machine>" or, of course, each other user defined folder.

The files are structured in XML format and have the file extension .vbox as well as .vbox-prev. The name before the extension is equal to the name of the virtual machine. So, for example "<name of the virtual machine>.vbox" and "<name of the virtual machine>.vbox-prev".

After opening the files in a text editor, you can add (or change) the following line in the section "<ExtraData>". This line configurates whether the time should be taken from the host system

<ExtraDataItem name="VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" value="1"/>

With setting "value" to "0", the time is synchronized, if "value" is set to "1", there is no synchronization with the host system.

Change Settings via Command Line

Instead of changing the XML configuration files manually using a text editor, you can also perform the changes from the command line. For this, you can enter the following command from the Terminal:

VBoxManage setextradata <Virtual Machine Name> "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "1"

Of course, you have to insert the name of the virtual machine, you would like to change, into the command.

The tool VBoxManage is located in the installation folder of VirtualBox. So, you have to either run the command directly from the installation folder or you have to specify the full path to VBoxManage to make it work.

Important: Exit VirtualBox before

VirtualBox is reading its settings at startup and storing its settings when closing it. Therefore, when applying changes to the configuration, you have to close all running virtual machines as well as VirtualBox itself.

Otherwise the changes will not become active or they will even be overwritten.

ReplyPositiveNegativeDateVotes
11 Vote

This works somtimes.

I think there must be a bug.

Sometimes my virtual machine is keeping its own date and time sometimes it will revert to the date and time of the system. I have double checked the settings and they are correct. I used the command and looked afterwards in the settings files to see if the settings were ok.
2021-07-25 at 22:57

ReplyPositive Negative
11 Vote

Some operating systems are checking and updating their time from the internet. When you let the system start with an individual time, that time might then be overwritten with the current time at startup again after the time sync. Maybe this is the reason for that behavior.

Usually the operating systems are providing an option that can be deactivated to prevent that automatic time synchronization.
2021-07-25 at 23:44

Positive Negative
Reply
Reply

About the Author

AvatarYou can find Software by Stefan Trost on sttmedia.com. Do you need an individual software solution according to your needs? - sttmedia.com/contact
Show Profile

 

Related Topics

Change Date of File

Tutorial | 0 Comments

PHP: Current Date and Time

Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.