Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UTC offset in minutes

Tags:

c#

.net

How can I get the difference between local time and UTC time in minutes (in C#)?

like image 429
tkl33 Avatar asked Jan 24 '12 20:01

tkl33


2 Answers

Use TimeZoneInfo:

TimeSpan delta = TimeZoneInfo.Local.GetUtcOffset();
double utcMinuteOffset = delta.TotalMinutes;
like image 181
BrokenGlass Avatar answered Sep 21 '22 05:09

BrokenGlass


This should give you what you need.

(DateTime.UtcNow - DateTime.Now).TotalMinutes;

Also you may find the .ToUniversalTime DateTime function of use.

like image 35
Adam S Avatar answered Sep 20 '22 05:09

Adam S