Set the 'bios' time of the virtual box.

Discussions about using Windows guests in VirtualBox.
trenien
Posts: 8
Joined: 5. Jun 2007, 01:24

Set the 'bios' time of the virtual box.

Post by trenien »

Under a linux host, I have a need to install XP and set it back in time from the start. Unfortunately, whatever I've been trying with Windows, it always gets back to the time settings of the host.

Since I was careful to uncheck the internet time server synchro, I guess XP sets its time directly from what it extracts from the bios.

Is there a way to set the virtual bios to a chosen date?
bodhi.zazen
Volunteer
Posts: 180
Joined: 17. May 2007, 16:02

Post by bodhi.zazen »

The time is correct on my windows guest after installing the additions.
If is a virtual machine, is it still broken ?
trenien
Posts: 8
Joined: 5. Jun 2007, 01:24

Post by trenien »

You misunderstand me. I don't want the virtual XP time to be correct, I want it to be set on whatever I choose it to be.
I just realized that among the additions there's a sync tool. That don't help, on the contrary.

So my question becomes: Is there a way to set the virtual bios time on a time and date of my choice, and can I have the additions installed with that sync tool deactivated somehow?
achimha
Volunteer
Posts: 217
Joined: 10. May 2007, 09:24

Post by achimha »

You can set a time offset in VBox 1.4.0:

Code: Select all

VBoxManage modifyvm <name> -biossystemtimeoffset <msec>
trenien
Posts: 8
Joined: 5. Jun 2007, 01:24

Post by trenien »

Thanks. That's exactly the kind of thing I was looking for - but knowing I have to set it back about 2 years in millisecond :shock: .

It isn't really documented in the user manual though. I could only find it mentionned at the beginning of the quick reference section: to set it back in time, do I just have to use it with a minus in front?

Code: Select all

VBoxManage modifyvm <name> -biossystemtimeoffset <-msec>
achimha
Volunteer
Posts: 217
Joined: 10. May 2007, 09:24

Post by achimha »

Exactly. Not all features of VirtualBox are documented. There are just too many features to document them all :-)
trenien
Posts: 8
Joined: 5. Jun 2007, 01:24

Post by trenien »

Ok, I just did it and it works perfectly.

Related question: If I define another offset afterward with the same command, does it replace the previous one, or is it added to it?
siking
Posts: 2
Joined: 18. Sep 2008, 17:50
Location: California
Contact:

Post by siking »

Old post, still a problem.

To answer the last poster, the time is replaced, not added. Which leads to my problem: how many milliseconds between $NOW and November 02, 2008 2AM PST? :( In case you're wondering: I am testing what happens to my stuff during daylight savings time change.

TIA
chungy
Volunteer
Posts: 132
Joined: 26. Jan 2008, 10:27

Post by chungy »

A little math goes a long way... 11 days left in September, 31 in October, and another day for getting to midnight Nov 02. You should be able to figure it out from here, add/subtract hours as necessary.
siking
Posts: 2
Joined: 18. Sep 2008, 17:50
Location: California
Contact:

Post by siking »

When I posted my question there were 12 days left in September. what about next week, what about next month, ...? In short: I was hoping for something generic. Something like the following:

Code: Select all

vboxdate () {
	# Adjust VM BIOS time to a given date
	secs=$(date –date "$*" +%s)    # convert supplied date to secs, since 1970-01-01
	let secs-=$(date +%s)           # subtract the date NOW
	msecs=$(( $secs * 1000 ))       # convert to millis
	echo Adjusting time ${msecs}ms
	VBoxManage modifyvm Vista -biossystemtimeoffset ${msecs};
 }
Sorry, but I can't help anyone on Windows.
asteriosgr
Posts: 1
Joined: 27. Sep 2008, 12:23

Post by asteriosgr »

what you mean by saying VBoxManage modifyvm <name> -biossystemtimeoffset <-msec>
and i need help on setting bios in 27 august 2003....any1 help please???
Higg's bosun
Posts: 1
Joined: 10. Oct 2008, 21:49

Handy Perl script

Post by Higg's bosun »

Here's a perl script I use. You may not have the Date::Manip module in your distribution, but you can get it from http://search.cpan.org/search?query=Dat ... p&mode=all

Code: Select all

#!/usr/bin/perl -w
use strict;
use Date::Manip;

my $start = join(' ', @ARGV);
my $sdate = ParseDate($start);
my $edate = ParseDate("now");
my $sepoch = UnixDate($sdate, "%s");
my $eepoch = UnixDate($edate, "%s");
my $msec = -1000 * ($eepoch - $sepoch);

print "Something like:\nVBoxManage modifyvm <name> -biossystemtimeoffset $msec\n";
$ perl msec.pl 6:30 PM 27 august 2003
Something like:
VBoxManage modifyvm <name> -biossystemtimeoffset -161636563000
$
Date::Manip has awesome parsing:
$ perl msec.pl 2 days ago
Something like:
VBoxManage modifyvm <name> -biossystemtimeoffset -172800000
$
If you get "Use of uninitialized value in subtraction (-) at msec.pl line 11.", you've gone past Date::Manip's awesomeness:
$ perl msec.pl next year
Use of uninitialized value in subtraction (-) at msec.pl line 11.
Something like:
VBoxManage modifyvm <name> -biossystemtimeoffset -1223670094000
$
Cheers,
HB
gungadout
Posts: 1
Joined: 20. Nov 2008, 05:38

How To Set The Virtual Bios Date Manually?

Post by gungadout »

Hi Folks,

The examples I've seen in the forum, seem to require programming an instruction into a php program or the like, then running that program. I am not familiar with that environment, so I cannot use that procedure.

Is there any way I can set the date manually?

Regards,

Gungadout
bismutant
Posts: 2
Joined: 16. Jun 2009, 10:57
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: Win XP

Re: Set the 'bios' time of the virtual box.

Post by bismutant »

hello, I agree with "gungadout"! Why isn`t there any simple way to freeze the time of a VM? Even if you end the Windows service W32time and uncheck time synchronisation with microsoft server the time is synchronisized...but fromthe bios? isn´t the bios freezed too like the operating system?
vbox4me2
Volunteer
Posts: 5218
Joined: 21. Nov 2008, 20:27
Location: Rotterdam
Contact:

Re: Set the 'bios' time of the virtual box.

Post by vbox4me2 »

Time is kept ontime by the Guest Additions, remove them to set your own time.
Post Reply