harmc0re Posted August 5, 2011 Share Posted August 5, 2011 (edited) Fix the time difference between osx86 andWindows in multiboot setups. Preface: When you installed osx86, dual-booting with Windows,you might notice your clock changed one or several hourswhen booting Windows right after osx86 and vice versa.Why does this happen? Macs save the universal time (aka UTC)of the world to the BIOS instead of the local timeof 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 taskbarwill read 2:02pm because Windows reads the time fromthe BIOS upon booting and assumes it's the local time.How can we fix this? The best way to fix this, in my opinion, is to make anadjustment to the osx86 installation, and not to your Windows OS becausethat's not where the problem is located, and on the other hand,I believe it's only logical that your BIOS time reflects your local time.In other words, we will create a script and a launchdaemon for your osx86 installationto switch between UTC and localtime every time you run osx86.This fix is tested and confirmed working on OS X 10.5.x - 10.9.x. (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.Or just use nano or vi if you're familiar with those. Whichever floats your boat.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.plistand 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-toggleThe second and third command will give our launchdaemon the right permissions:sudo chown root /System/Library/LaunchDaemons/org.osx86.localtime-toggle.plistsudo chmod 644 /System/Library/LaunchDaemons/org.osx86.localtime-toggle.plistThe final command will load our launchdaemon.sudo launchctl load -w /System/Library/LaunchDaemons/org.osx86.localtime-toggle.plistNow, 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. Edited December 28, 2013 by harmc0re 12 Link to comment Share on other sites More sharing options...
ronsega Posted August 7, 2011 Share Posted August 7, 2011 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 Link to comment Share on other sites More sharing options...
harmc0re Posted August 7, 2011 Author Share Posted August 7, 2011 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... Link to comment Share on other sites More sharing options...
snackole Posted August 7, 2011 Share Posted August 7, 2011 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. 1 Link to comment Share on other sites More sharing options...
Ryohei47 Posted August 8, 2011 Share Posted August 8, 2011 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 Link to comment Share on other sites More sharing options...
harmc0re Posted August 8, 2011 Author Share Posted August 8, 2011 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. 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. ... 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)? Link to comment Share on other sites More sharing options...
macq Posted August 8, 2011 Share Posted August 8, 2011 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 Link to comment Share on other sites More sharing options...
WallyFTW Posted August 8, 2011 Share Posted August 8, 2011 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. 1 1 Link to comment Share on other sites More sharing options...
snackole Posted August 8, 2011 Share Posted August 8, 2011 You can only red the HFS drives. Do a search for BootCamp drivers and install them on your Windows drive. Link to comment Share on other sites More sharing options...
harmc0re Posted August 9, 2011 Author Share Posted August 9, 2011 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? ... 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. Link to comment Share on other sites More sharing options...
jamesah Posted August 9, 2011 Share Posted August 9, 2011 Thanks for both the fixes. 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. Link to comment Share on other sites More sharing options...
nyolc8 Posted August 10, 2011 Share Posted August 10, 2011 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? Link to comment Share on other sites More sharing options...
nozyczek Posted August 10, 2011 Share Posted August 10, 2011 Easiest fix I've found: Boot into Windows. Run --> Regedit Agree, much cleaner https://sites.google.com/site/nozyczek/home...windows-and-osx I have been using registry method since the beginning. No problems. nozyczek Link to comment Share on other sites More sharing options...
Ryohei47 Posted August 12, 2011 Share Posted August 12, 2011 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 Link to comment Share on other sites More sharing options...
harmc0re Posted August 13, 2011 Author Share Posted August 13, 2011 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. Link to comment Share on other sites More sharing options...
harmc0re Posted August 14, 2011 Author Share Posted August 14, 2011 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. 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. 1 Link to comment Share on other sites More sharing options...
trasman Posted March 28, 2012 Share Posted March 28, 2012 But still' date=' in my opinion, I think it's better to fix this on the Mac OS X side.[/quote'] Just my thought. Thanks for the guide. Link to comment Share on other sites More sharing options...
coolaks Posted June 29, 2012 Share Posted June 29, 2012 Thanks a lot for this guide! I found this today and fixed my Lion installation! Link to comment Share on other sites More sharing options...
skim32 Posted February 17, 2013 Share Posted February 17, 2013 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. 1 Link to comment Share on other sites More sharing options...
dannymichel Posted March 25, 2013 Share Posted March 25, 2013 Thank you very much. Link to comment Share on other sites More sharing options...
pashoni Posted April 1, 2013 Share Posted April 1, 2013 I think That I have found the easiest solution for this problem. I think that the only thing you should do is change the time zone on your mac insallation. Here is my example: My mac was showing 17:00 o'clock instead of the 15:00, which was the time at the moment. I'm living in time zone X and all I needed to do was to change it to X-2 time zone and lock the changes. I've restarted my pc serveral times and both Windows and Mac are showing the right time. I hope someone else is going to try this, in order to see if this really works. Link to comment Share on other sites More sharing options...
Gringo Vermelho Posted April 1, 2013 Share Posted April 1, 2013 Yeah but now your time zone is wrong. This remains the best way because it eliminates the issue completely, with zero undesirable side effects. Boot into Windows.Run --> RegeditBrowse 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. ...unless you count your BIOS clock now showing UTC as undesirable of course. But why would you. Link to comment Share on other sites More sharing options...
MegaloDon Posted June 13, 2013 Share Posted June 13, 2013 Before the osx86 installation, the bios time is the localtime, so I think it should stay that way. I think people are missing his point here. We are talking about a hackintosh here. A PC whose BIOS is designed to have the time set in local time. Macs are designed for UTC. If you use the regedit fix, the time will be wrong in the BIOS and possibly cause other problems (like skim32's WMC problem). Also be careful using bootcamp on a hackintosh. It might screw up the boot sector of your Windows installation. Keep in mind that bootcamp is designed for real Macs which use EFI boot. 1 Link to comment Share on other sites More sharing options...
b1gdadd1 Posted October 26, 2013 Share Posted October 26, 2013 I just converted my work PC into a dual-boot Win7 and ML machine . The script and launchdaemon solved my annoying time difference. Thanks harm! Link to comment Share on other sites More sharing options...
harmc0re Posted October 27, 2013 Author Share Posted October 27, 2013 I just converted my work PC into a dual-boot Win7 and ML machine . The script and launchdaemon solved my annoying time difference. Thanks harm! You are welcome! If you read through the comments you may have noticed that some people are sceptical on this approach. That's why I'm glad to hear other people prefering this method. I wrote this guide two years ago and I still stand strong behind my statement that this is the best possible fix. OS X causes the issue, and it should be fixed in OS X as well. Thanks for your reply, and congrats on the dual-boot setup. Link to comment Share on other sites More sharing options...
Recommended Posts