Currently my application is using DateTime.Now() to display the date and time. I observed that this method doesn't reflect the date time correctly when I change the time zone. It still displays the date and time of the previous time zone which was set to my appliaction.
Hence I rebooted my application and after that it displays the correct date and time based on the selected time zone.
Please help me in finding the correct API which reflects the date and time correctly if I change the time zone ( It should be same as reflecting correct date and time while changing the time zone in operating system clock)
Praveen NPosted Dec 23, 2013, 12:12 AM
Changing Windows system settings sends out a WM_SETTINGCHANGE message to all top level windows. Your application needs to handle this message (which means you must have a window).
.NET provides the convenient SystemEvents class to help with this. The TimeChanged event is the one you'll probably want to handle if you care about time zone or system time changes.
The time zone is cached so you'll need to call TimeZoneInfo.ClearCachedData before DateTime.Now will reflect the new value.