Jump to content

fluid | fixed

Fix the time difference between osx86 and Windows in multiboot setups.


  • Please log in to reply
22 replies to this topic

#1
harmc0re

harmc0re

    InsanelyMac Protégé

  • Members
  • PipPip
  • 78 posts
  • Gender:Male

Fix the time difference between osx86 and
Windows in multiboot setups.


Preface: When you installed osx86, dual-booting with Windows,
you might notice your clock changed one or several hours
when booting Windows right after osx86 and vice versa.
There are a few fixes out there that apply to a Windows registry edit,
but the actual cause is your osx86 installation.

Why does this happen? Macs save the universal time (aka UTC)
of the world to the BIOS instead of the local time
of the time zone you live in (aka localtime).
And Windows assumes the BIOS time is the local time.

Wait, what? For instance, while running osx86,
the clock on your screen could read 4:02pm (local time),
but in your BIOS, the time could be 2:02pm (universal time).
And if you would reboot to Windows, the clock in the taskbar
will read 2:02pm because Windows reads the time from
the BIOS upon booting and assumes it's the local time.

How can we fix this? The best way to fix this, is to make an adjustment to the osx86 installation,
and not to your Windows OS because that's not where the problem is located.
In other words, we will create a script and a launchdaemon for your osx86 installation
to switch between UTC and localtime every time you run osx86.
Also note that this fix is for OS X 10.5 and above. (it might work on older versions of OS X though, but I can't test it.)

The scripts are made in plain text, to configure TextEdit to create plain text files, open up TextEdit's preferences window, and click "Plain text".
Just like in this screenshot.

1. First, we will make the script.
    Create a file named localtime-toggle and place it in /sbin.
#!/bin/sh
	  
	  to_utc() {
	  echo "localtime-toggle: Toggling to UTC."
	  date -f %m%d%H%M%Y `date -u +%m%d%H%M%Y`
	  }
	  
	  to_localtime() {
	  echo "localtime-toggle: Toggling to localtime."
	  date -u -f %m%d%H%M%Y `date +%m%d%H%M%Y`
	  }
	  
	  trap 'to_localtime; exit' term
	  to_utc
	  { while true; do sleep 86400; done; } &
	  wait

2. Second, we will write the launchdaemon.

    Create a file named org.osx86.localtime-toggle.plist
    and place it in /System/Library/LaunchDaemons.

<?xml version="1.0" encoding="UTF-8"?>
	   <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
	   <plist version="1.0">
	   <dict>
		<key>Label</key>
		<string>org.osx86.localtime-toggle</string>
		<key>Program</key>
		<string>/sbin/localtime-toggle</string>
		<key>KeepAlive</key>
		<true/>
		<key>RunAtLoad</key>
		<true/>
		<key>HopefullyExitsFirst</key>
		<true/>
	  </dict>
	   </plist>

3. Now, we have to execute some commands.


    The first command makes our script executable:
        $ sudo chmod +x /sbin/localtime-toggle

    The second and third command will give our launchdaemon the right permissions:
        $ sudo chown root /System/Library/LaunchDaemons/org.osx86.localtime-toggle.plist
        $ sudo chmod 644
/System/Library/LaunchDaemons/org.osx86.localtime-toggle.plist

    The final command will load our launchdaemon.
        $ sudo launchctl load -w /System/Library/LaunchDaemons/org.osx86.localtime-toggle.plist

Now, if all went well, upon pressing enter on that last command, you should notice the time changed again.
If not, you did something wrong.
Don't worry,
check if the scripts you made are correct, if they are plain-text,
and if they have the correct names and places.
Also, press up in the terminal to see the history of commands you pressed, and check if they are correct.


4. Sync the clock with the internet, or manually correct the time, and you're done! :)


Finally, a few notes: I made
this guide because there are a few different ways described on the internet that deal with this problem, but I think they are hard to find or incomplete.

I took some time and effort to write this, so if...
this solved your problem,

this didn't solve your problem,
I made any mistakes on the grammar or the technical side,

please write a comment to let me know.



Harm.

#2
ronsega

ronsega

    InsanelyMac Protégé

  • Members
  • Pip
  • 35 posts
This works thanks sooo much!  I changed locations of the script (/usr/local/sbin) and the launchdaemon (/Library/LaunchDaemons) in my installation of your scripts.  but other than after running your scripts to boot into windows 7, the time was correct and then back into Lion and it works 100% so far   :unsure:

I do notice two running instances/processes of the localtime-toggle script though, is that normal?

$ ps -ef | grep localtime-toggle
	0	76	 1   0  4:00PM ??		 0:00.01 /bin/sh /usr/local/sbin/localtime-toggle
	0	88	76   0 11:00PM ??		 0:00.00 /bin/sh /usr/local/sbin/localtime-toggle


#3
harmc0re

harmc0re

    InsanelyMac Protégé

  • Members
  • PipPip
  • 78 posts
  • Gender:Male

View Postronsega, on Aug 7 2011, 08:08 AM, said:

This works thanks sooo much!  I changed locations of the script (/usr/local/sbin) and the launchdaemon (/Library/LaunchDaemons) in my installation of your scripts.  but other than after running your scripts to boot into windows 7, the time was correct and then back into Lion and it works 100% so far   :)

I do notice two running instances/processes of the localtime-toggle script though, is that normal?

$ ps -ef | grep localtime-toggle
	0	76	 1   0  4:00PM ??		 0:00.01 /bin/sh /usr/local/sbin/localtime-toggle
	0	88	76   0 11:00PM ??		 0:00.00 /bin/sh /usr/local/sbin/localtime-toggle
Same here, ronsega:

Harm-Claeyss-HackBook-Pro:~ harm$ ps -ef | grep localtime-toggle
	0  1690	 1   0   0:00.01 ??		 0:00.01 /bin/sh /sbin/localtime-toggle
	0  1740  1690   0   0:00.00 ??		 0:00.00 /bin/sh /sbin/localtime-toggle
  501 54358 53986   0   0:00.00 ttys000	0:00.00 grep localtime-toggle


Thanks to let me know, I don't know why there are two instances though...

#4
snackole

snackole

    InsanelyMac Sage

  • Members
  • PipPipPipPipPipPip
  • 412 posts
  • Gender:Male
  • Location:US
If you install Bootcamp drivers on your Windows hard drive it will fix that and allow you to see your HFS drives and your magic mouse will work too.

#5
Ryohei47

Ryohei47

    InsanelyMac Protégé

  • Members
  • Pip
  • 24 posts
im having trouble saving with the right file endings, i cant get it to save as a normal file or .plist correctly. also, when i did $ sudo chmod +x /sbin/localtime-toggle, it said -bash: $: command not found

#6
harmc0re

harmc0re

    InsanelyMac Protégé

  • Members
  • PipPip
  • 78 posts
  • Gender:Male

View PostRyohei47, on Aug 8 2011, 07:40 AM, said:

im having trouble saving with the right file endings, i cant get it to save as a normal file or .plist correctly. also, when i did $ sudo chmod +x /sbin/localtime-toggle, it said -bash: $: command not found

You need to leave out the $-signs and the extra space after that.
Sometimes people like to add a $ before a command to say "this is a Terminal command"
Sorry, I didn't want to confuse you.

If you enter these two commands in Terminal:
sudo cp /sbin/disklabel Desktop/localtime-toggle          (Note that this command may ask for your password!)
cp Desktop/localtime-toggle Desktop/org.osx86.localtime-toggle.plist

There will be two extra files added to your desktop.
You can right-click on them and choose Open with -> Other...
Then choose TextEdit in the list.
You will see a lot of weird letters there, just delete all of them
Then you can type the things from my guide and save the files.

View Postsnackole, on Aug 8 2011, 12:53 AM, said:

If you install Bootcamp drivers on your Windows hard drive it will fix that and allow you to see your HFS drives and your magic mouse will work too.
Oh, thanks, I didn't know that.

But still, in my opinion, I think it's better to fix this on the Mac OS X side.
And if you see my signature, you will see that I have 2 Windows OSes, so this remains the best solution for me.


View Postsnackole, on Aug 8 2011, 12:53 AM, said:

... and allow you to see your HFS drives ...
Interesting, can you specify "see your HFS drives"?
Can you read the files on them, can you write files on them (even though the drives are Journaled)?

#7
macq

macq

    InsanelyMac Protégé

  • Members
  • PipPip
  • 97 posts

View Postsnackole, on Aug 7 2011, 11:53 PM, said:

If you install Bootcamp drivers on your Windows hard drive it will fix that and allow you to see your HFS drives and your magic mouse will work too.
Could you elaborate on as to how to do this.

Thanks

#8
WallyFTW

WallyFTW

    InsanelyMac Protégé

  • Members
  • PipPip
  • 56 posts
  • Gender:Male
  • Location:San Jose, CA
Easiest fix I've found:

Boot into Windows.
Run --> Regedit

Browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\
Check if a DWORD (32-Bit) called "RealTimeIsUniversal" exists. If it does, make sure its value "1". If it doesn't make a new DWORD (32-Bit) and call it "RealTimeIsUniversal" and have it set a value of 1.

Reboot into OS X.
Set the time via time.apple.com.
Reboot into Windows.
All should be well.

#9
snackole

snackole

    InsanelyMac Sage

  • Members
  • PipPipPipPipPipPip
  • 412 posts
  • Gender:Male
  • Location:US
You can only red the HFS drives. Do a search for BootCamp drivers and install them on your Windows drive.

#10
harmc0re

harmc0re

    InsanelyMac Protégé

  • Members
  • PipPip
  • 78 posts
  • Gender:Male

View PostWallyFTW, on Aug 8 2011, 07:12 PM, said:

Easiest fix I've found:

Boot into Windows.
Run --> Regedit

Browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\
Check if a DWORD (32-Bit) called "RealTimeIsUniversal" exists. If it does, make sure its value "1". If it doesn't make a new DWORD (32-Bit) and call it "RealTimeIsUniversal" and have it set a value of 1.

Reboot into OS X.
Set the time via time.apple.com.
Reboot into Windows.
All should be well.
Are you kidding me? Have you read the guide?

  

View PostHarmcl, on Aug 5 2011, 07:13 PM, said:

... How can we fix this? The best way to fix this, is to make an adjustment to the osx86 installation,
and not to your Windows OS because that's not where the problem is located. ...
Okay, you can tell Windows to treat the bios time as UTC, or tell Mac to treat the bios time as localtime, it's just the same thing. But I rather apply a fix to the Mac OS, because that's where the problem started.

#11
jamesah

jamesah

    InsanelyMac Protégé

  • Members
  • PipPip
  • 50 posts
Thanks for both the fixes. :D I've been too lazy to mess with it because I've been more concerned about getting the installs working properly but once I finish, this will be done.

#12
nyolc8

nyolc8

    InsanelyMac Sage

  • Members
  • PipPipPipPipPipPip
  • 462 posts
  • Gender:Male
  • Location:Budapest, Hungary

View PostHarmcl, on Aug 9 2011, 02:24 AM, said:

Are you kidding me? Have you read the guide?
What is the problem with it? I'm using this registry method for a year now, without any problem. Why scripting better, what are the benefits of it?

#13
nozyczek

nozyczek

    InsanelyMac Protégé

  • Members
  • PipPip
  • 57 posts

View PostWallyFTW, on Aug 8 2011, 01:12 PM, said:

Easiest fix I've found:

Boot into Windows.
Run --> Regedit


Agree, much cleaner

https://sites.google...windows-and-osx

I have been using registry method since the beginning. No problems.

nozyczek

#14
Ryohei47

Ryohei47

    InsanelyMac Protégé

  • Members
  • Pip
  • 24 posts

View PostHarmcl, on Aug 8 2011, 08:35 AM, said:

You need to leave out the $-signs and the extra space after that.
Sometimes people like to add a $ before a command to say "this is a Terminal command"
Sorry, I didn't want to confuse you.

If you enter these two commands in Terminal:
sudo cp /sbin/disklabel Desktop/localtime-toggle          (Note that this command may ask for your password!)
cp Desktop/localtime-toggle Desktop/org.osx86.localtime-toggle.plist

There will be two extra files added to your desktop.
You can right-click on them and choose Open with -> Other...
Then choose TextEdit in the list.
You will see a lot of weird letters there, just delete all of them
Then you can type the things from my guide and save the files.

i tried editing localtime-toggle, but it says i didnt have sufficient permission to save

#15
harmc0re

harmc0re

    InsanelyMac Protégé

  • Members
  • PipPip
  • 78 posts
  • Gender:Male

View PostRyohei47, on Aug 12 2011, 06:22 AM, said:

i tried editing localtime-toggle, but it says i didnt have sufficient permission to save
Oh, sorry about that.
Can you save org.osx86.localtime-toggle.plist?
If you do

sudo chmod 777 Desktop/localtime-toggle

and (only if you also have problems to save the org.osx86.localtime-toggle.plist file)

sudo chmod 777 Desktop/org.osx86.localtime-toggle.plist

And you should be able to edit and save them both then.

#16
STLVNUB

STLVNUB

    InsanelyMac Legend

  • Coders
  • 976 posts
  • Gender:Male
My .05 cents worth.

I use the windows regedit trick.
As OS X is my main OS, it makes sense to leave it  on Universal Time.
This works extremely well, having used it for quite some time.

It's all down to personal preference of course, but agree that regedit is way easier.

#17
harmc0re

harmc0re

    InsanelyMac Protégé

  • Members
  • PipPip
  • 78 posts
  • Gender:Male
I have two Windows OSes, so for me it makes sense to use this scripting method. :)

I don't see why people fiddle around in Windows to make the time in sync. :unsure:
Before the osx86 installation, the bios time is the localtime, so I think it should stay that way.

But that's just my opinion then.

#18
trasman

trasman

    InsanelyMac Protégé

  • Members
  • Pip
  • 24 posts

Quote

But still, in my opinion, I think it's better to fix this on the Mac OS X side.
Just my thought.

Thanks for the guide.

#19
coolaks

coolaks

    InsanelyMac Protégé

  • Members
  • Pip
  • 37 posts
Thanks a lot for this guide! I found this today and fixed my Lion installation!

#20
skim32

skim32

    InsanelyMac Protégé

  • Members
  • Pip
  • 2 posts
Thanks.  OP.  Was looking for a fix on the OSX side forever.  For everyone who keeps saying that the Windows Registry hack is the "better" way.  You guys aren't fully correct.  For people like me who use Windows Media Center with a TV tuner card, the windows registry fix is not a viable solution.  It screws up the recording schedules.  The only fix for people who use WMC, is the OSX fix.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2013 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   Web hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy