Reputation: 4749
In C#, what is the difference between UTC and Universal Time? What are the functions available?
Upvotes: 0
Views: 2435
Reputation: 74
UTC = Universal Time.
You can convert your current local time to UTC by
DateTime dt= DateTime.UtcNow;
or convert a specified date/time by
TimeZoneInfo myTZInfo = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
// DateTime.SpecifyKind(Convert.ToDateTime("04:35 AM"), DateTimeKind.Unspecified), myTZInfo) tells whether you are conetring a local time or UTC, you can always leave it as unspecified
TimeZoneInfo.ConvertTimeToUtc(DateTime.SpecifyKind(Convert.ToDateTime("2015-01-06 14:00:00.000"), DateTimeKind.Unspecified), myTZInfo).ToString("hh:mm tt")
you can get all time zone ids by==>
ReadOnlyCollection<TimeZoneInfo> tzc= TimeZoneInfo.GetSystemTimeZones();
Upvotes: 0
Reputation: 754468
I would think they're both the same - according to Wikipedia, UTC is Coordinated *Universal* Time
.
.NET supports UTC through a number of function on the DateTime
struct. E.g. there is are functions like DateTime.ToUniversalTime
(and DateTime.ToLocalTime
to convert back, of course) or DateTime.UtcNow
available.
Upvotes: 5
Reputation: 8018
No difference. DateTime.UtcNow gives you the current time in UTC. The Timezone class has functions to convert to and from UTC date/time to date/time in any timezone.
Upvotes: 2