To me they're both the same. Is UtcNow simply a shortcut?
UtcNow tells you the date and time as it would be in Coordinated Universal Time, which is also called the Greenwich Mean Time time zone - basically like it would be if you were in London England, but not during the summer. DateTime. Now gives the date and time as it would appear to someone in your current locale.
The ToUniversalTime method converts a DateTime value from local time to UTC. To convert the time in a non-local time zone to UTC, use the TimeZoneInfo. ConvertTimeToUtc(DateTime, TimeZoneInfo) method. To convert a time whose offset from UTC is known, use the ToUniversalTime method.
Since our system is running on Ubuntu 20.04 Linux server, from our tests, we found that all DateTime. Now call will return a UTC time, not local time.
Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time. public: static property DateTime Now { DateTime get(); }; C# Copy.
Actually it's the other way around. The Now
property is implemented as:
public static DateTime Now { get { return UtcNow.ToLocalTime(); } }
There is a long example in the Documentation for UtcNow which shows them to be the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With