moksh freelancer
moksh freelancer

Reputation: 105

"How to get real date time even user changes system date" in c# windows application

I am using MessageBox.Show(DateTime.Now.ToString()); to get date and time. My problem is when I change system date it displays updated date not a real date. what I need is real date and time not operating system's date and time. please do help me. Thank you.

Upvotes: 0

Views: 2453

Answers (1)

moritzg
moritzg

Reputation: 4394

You could get the current time from some server over the internet like this for example: https://timezonedb.com/api

Maybe it's possible to get the time from the real time clock component on the motherboard, but the user could also just remove the CMOS battery or set the time in BIOS.

When you first run your program, save the current time to somewhere (hidden) on the disk, update that file every 15 minutes or so, and if the time is changing significantly like more than 1 hour, compare it to the file.

Otherwise there's no possible way to control this.

Upvotes: 1

Related Questions