How does C# DateTime determine it’s Now and Today times

Couldn't find anything on the internet nor the documentation on this. Where does C# get it's DateTime.Now or DateTime.Today from? These are localized values. Is it determined by Windows? Or does IIS influence this? I want to know what exactly parses the real now time to C# and what can influence it.

Why I want to know this

I am having some weird API behavior where some things are returned hours before they should. Which is most likely related to time zones. VPS and client are in the same time zone so I am wondering what can influence such behavior.

I am doing a hard ...FromDate.Date <= DateTime.Today.Date and for some reason I sometimes get records that are "from" tomorrow. Where 2021-02-21 <= 2021-02-20 seems to be "true". True meaning that the DateTime.Today seems to be off. Only seeing this behavior around after 10 PM so hours before actual midnight suggesting it has something to do with time zones.

If you have any idea on this behavior please tell me

Read more here:

Content Attribution

This content was originally published by Roy Berris at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: