What does System.DateTime.Now return in C#?

asp.net, c#

Solution

`DateTime.Now` performs a few steps:

- Get UTC time from the OS

- Get timezone info from the registry of the machine on which it is executing

- Use that timezone information to resolve UTC to local time (again, local to the executing machine)

If this returns Client time, how to get Server time and vice-versa?

If you are dealing with clients in multiple timezones, it's often useful to store all dates in UTC and then store the client's timezone for conversion purposes.

JavaScript can also be useful for resolving UTC dates to client time and/or for obtaining time in the web browser.

Geolocation (e.g. examining the user's IP) can also be used to make a guess as to the user's location/timezone, though it's not guaranteed to be accurate.

Problem

What time does the System.DateTime.Now return in C#? Is it the Local Machine (Client) Time or Server (IIS) Time? If this returns Client time, how to get Server time and vice-versa? EDIT OK, sorry it was a mistake that I put paranthesis. But question stands whether local time or server time.

Original source