# Time is always wrong



## RogellParadox (Dec 1, 2021)

I have been having a real bad time trying to fix the time. I have a multiboot and you all know how messed up it gets when multibooting.
My timezone is GMT -3. So, for instance, it was supposed to be like this

```
qua  1 dez 2021 10:19:52 -03
```

and not like this

```
qua  1 dez 2021 13:19:52 -03
```

Yes, I tried tzsetup, tons of times, never works for nothing.
Tried cp /usr/share/zoneinfo/Region/City /etc/localtime and also didn't work
Tried "RealTimeIsUniversal"=dword:00000001 on Windows (It was already set before) and nothing helps.
Tried using NTP and Plasma's NTP, but I don't want to use NTP again because it always messes Windows' time - also when I use NTP and block Window's automatic time update, if I spend some time on FreeBSD and go back to Windows, it's like time had stopped. (Example: I boot Windows at 09:00, reboot on FreeBSD, spend some good 25 minutes on it. Reboot on Windows. Instead of 09:25, it would show me 09:00 - the very first time before booting up FreeBSD).

I know I fixed it long time ago without having to mess with the mentioned above but I can't remember how I did it.


----------



## SirDice (Dec 1, 2021)

If you dual boot with windows, run tzsetup(8). Do NOT pick YES when asked if the CMOS clock is running UTC, make sure you set this to NO. Windows assumes your CMOS clock is running on local time.


----------



## RogellParadox (Dec 1, 2021)

SirDice said:


> If you dual boot with windows, run tzsetup(8). Do NOT pick YES when asked if the CMOS clock is running UTC, make sure you set this to NO. Windows assumes your CMOS clock is running on local time.



As mentioned before, tzsetup never works.


----------



## SirDice (Dec 1, 2021)

Works just fine. Again, run tzsetup(8). Make sure to pick NO when asked if your clock is running UTC. Then run `ntpdate 0.pool.ntp.org` (better yet, find an NTP source closer to home: https://support.ntp.org/bin/view/Servers/WebHome#Finding_A_Time_Server). Enable NTP, `sysrc ntpd_enable="YES"` and start the service `service ntpd start`.


----------



## RogellParadox (Dec 1, 2021)

SirDice said:


> Works just fine. Again, run tzsetup(8). Make sure to pick NO when asked if your clock is running UTC. Then run `ntpdate 0.pool.ntp.org` (better yet, find an NTP source closer to home: https://support.ntp.org/bin/view/Servers/WebHome#Finding_A_Time_Server). Enable NTP, `sysrc ntpd_enable="YES"` and start the service `service ntpd start`.


Again, it doesn't work. And when I use NTP, again, as I said, Windows time gets messed up.
Please read my original post.


----------



## SirDice (Dec 1, 2021)

RogellParadox said:


> Please read my original post.


I did and I'm telling you how to fix it. It's fine if you just want to ignore it.


----------



## RogellParadox (Dec 1, 2021)

SirDice said:


> I did and I'm telling you how to fix it. It's fine if you just want to ignore it.



Yes, it works so good that time keeps wrong.
Do you think I haven't tried tons of "solutions" I searched on this forum, Reddit and so on?
If you don't really want to help, why bother commenting?


----------



## Menelkir (Dec 1, 2021)

Then keep your time as UTC and make windows work with UTC:

```
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation" /v RealTimeIsUniversal /d 1 /t REG_DWORD /f
```

Update: Nevermind, I say you already tried that. I think you have a hardware issue.


----------



## RogellParadox (Dec 1, 2021)

Menelkir said:


> Then keep your time as UTC and make windows work with UTC:
> 
> ```
> reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation" /v RealTimeIsUniversal /d 1 /t REG_DWORD /f
> ```



It's also said in my first post I tried that and Windows is still forcing its time settings


```
Tried "RealTimeIsUniversal"=dword:00000001 on Windows (It was already set before) and nothing helps.
```

Seriously...


----------



## SirDice (Dec 1, 2021)

RogellParadox said:


> Example: I boot Windows at 09:00, reboot on FreeBSD, spend some good 25 minutes on it. Reboot on Windows. Instead of 09:25, it would show me 09:00 - the very first time before booting up FreeBSD


Timezones don't work in 25 minute time frames. The timezone is not the issue here. Neither is NTP because that also doesn't cause a 25 minute time difference. Either your CMOS clock is broken or you are using some really dodgy time servers.


----------



## Menelkir (Dec 1, 2021)

RogellParadox said:


> It's also said in my first post I tried that and Windows is still forcing its time settings
> 
> 
> ```
> ...


"Seriously" you also didn't read my update line.


----------



## SirDice (Dec 1, 2021)

If you have set Windows to use UTC then make sure to answer YES to the UTC question from tzsetup(8).


----------



## bakul (Dec 1, 2021)

RogellParadox said:


> Tried using NTP and Plasma's NTP, but I don't want to use NTP again because it always messes Windows' time - also when I use NTP and block Window's automatic time update, if I spend some time on FreeBSD and go back to Windows, it's like time had stopped. (Example: I boot Windows at 09:00, reboot on FreeBSD, spend some good 25 minutes on it. Reboot on Windows. Instead of 09:25, it would show me 09:00 - the very first time before booting up FreeBSD).


Did you try `touch /etc/wall_cmos_clock`? And don’t block Windows auto time update _or_ ntp.


----------



## VladiBG (Dec 1, 2021)

Replace your CMOS battery


----------



## gpw928 (Dec 1, 2021)

Have you tried forcing the date to be set when you boot:
	
	



```
[f13.130] $ grep ntp /etc/rc.conf
ntpdate_enable="YES"
ntpd_enable="YES"
```
This should cover a range of maladies, including motherboard battery problems.


----------



## RogellParadox (Dec 1, 2021)

VladiBG said:


> Replace your CMOS battery



There's nothing wrong with my CMOS battery. I have a multiboot and set NTP. As I said, after quitting FreeBSD and going back to Windows (also tried with my Hackintosh) time is messed up and takes some while to be synced. A problem that shouldn't exist if I wasn't forced to use NTP.


----------



## RogellParadox (Dec 1, 2021)

SirDice said:


> Timezones don't work in 25 minute time frames. The timezone is not the issue here. Neither is NTP because that also doesn't cause a 25 minute time difference. Either your CMOS clock is broken or you are using some really dodgy time servers.



It was simply an example, I didn't mention a timezone at all. Activated NTP and it happened just as I said (also like I just mentioned in the comment above)
Here it does cause something, as if, after NTP is activated, Windows (and other systems) couldn't count the time spent on FreeBSD and would show the wrong time.


----------



## gpw928 (Dec 1, 2021)

RogellParadox said:


> after quitting FreeBSD and going back to Windows (also tried with my Hackintosh) time is messed up


What happens if you shut down Windows (power off) for some time and reboot Windows?  Does Windows show the correct time immediately after booting?

[Using NTP is not going to corrupt the motherboard clock!  If any O/S has the wrong time, then you have a flat battery, broken hardware, set the time wrongly, or O/S mis-configured.]


----------



## a6h (Dec 2, 2021)

A temporary solution:

Open an elevated PowerShell
`C:> powershell.exe -Command "Start-Process cmd -Verb RunAs"`

Change the w32time service to automatic:
`PS> sc config w32time start=auto`

Reboot the PC:
`PS> shutdown /r`


----------



## grahamperrin@ (Dec 4, 2021)

RogellParadox said:


> GMT -3



Probably irrelevant, but I thought of your topic this morning when I read <https://lists.freebsd.org/archives/freebsd-hackers/2021-December/000595.html> ▶ <https://github.com/eggert/tz/blob/2018g/etcetera#L38-L44>


----------



## grahamperrin@ (Dec 11, 2021)

gpw928 said:


> `ntpdate_enable="YES"`



<https://cgit.freebsd.org/src/commit/?id=4d8f5c69c77914ba5dddcc24595e28a1e7ddc2cc> (2018-08-22)



> > *Note that ntpd_sync_on_start is a preferred alternative to ntpdate_enable.* …


----------



## mark_j (Dec 11, 2021)

It may be the preferred method but I'm fairly certain bsdinstall writes that out when you select ntpdate as a post install option.
I'm quite prepared to be wrong, though.


----------



## grahamperrin@ (Dec 11, 2021)

mark_j said:


> … bsdinstall …



Thanks! 

FreeBSD bug 260341 – Consistency with regard to ntpd_sync_on_start


----------

