FORSMILE
JA
開発記事2021/09/15

How to Change Date and Time in VirtualBox and Troubleshoot When It Reverts [Development Environment]

A note on how to change the system time when working in a local environment created with VirtualBox.

Back to Blog

A note on how to change the system time when working in a local environment created with VirtualBox.

You can easily change the time itself using the `date` command in Linux.

However, since VirtualBox synchronizes its time with an NTP (Network Time Protocol) server, the changed time will quickly revert.

HOW TO DISABLE TIME SYNCHRONIZATION IN VIRTUALBOX WHEN EXECUTING COMMANDS

text
// Stop time synchronization
service vboxadd-service stop 

// Change the time
date -s "2017/12/24 12:00:00"

// Resume time synchronization
service vboxadd-service start

Unless you're in a very specific situation, the method above should allow you to change the time.

HOW TO DISABLE TIME SYNCHRONIZATION AT VM STARTUP

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

Run this command with the VirtualBox installation folder as your current directory, or specify the path to `VBoxManage.exe`.

By changing the "1" at the end back to "0", you can re-enable synchronization. Since this is a startup setting, a VM restart will be required.

Although brief, this explains how to change the date and time in VirtualBox and how to deal with it reverting.

RECOMMENDED BOOKS RELATED TO DEVELOPMENT ENVIRONMENTS

While it's hard to recommend one specific book as it depends on the language and OS you're using, I'll introduce some that offer easy explanations.

Copy-Paste OK! Fundamentals of Web Server Setup for Mac, Learned While Building VMs: Accelerate Web Development Testing! A Step-by-Step Guide to Building Truly Useful Virtual Servers.

📦
Amazon で関連書籍・ツールを検索
web development programming book
Amazonで探す →(アソシエイトリンク)
Related articles