I have the following code, which should return an offset of 60 (to show that in the UK at present, we are in British Summer Time - ie. 60 minutes ahead of GMT):
var info = TimeZoneInfo.FindSystemTimeZoneById("Greenwich Standard Time");
DateTimeOffset localServerTime = DateTimeOffset.Now;
double off = localServerTime.Offset.TotalMinutes;
return off;
However, it returns 0.
Could anyone please help fix this for me?
BST Only in the UK GMT is the standard time zone in Ireland and the United Kingdom, including England, Wales, Scotland, and Northern Ireland. All of these countries use DST during part of the year, but under different names. The United Kingdom and its Crown dependencies use British Summer Time during the DST period.
BST begins at 01:00 GMT every year on the last Sunday of March and ends at 01:00 GMT (02:00 BST) on the last Sunday of October.
GMT is similar to Coordinated Universal Time (UTC) which is the standard time zone of the world while BST is GMT plus one hour. 3. The use of both GMT and BST started in the United Kingdom with GMT being used during the winter and BST during the summer.
To save energy and help the war effort, the Summer Time Act 1916 advanced the clocks in the UK for 1 hour from May 21 until October 1 in the same year. Summer time, or DST, proved so popular that it was named British Summer Time (BST) and the seasonal practice kept.
Use TimeZoneInfo.IsDaylightSavingTime Method (DateTimeOffset) to find if it is currently Daylight saving for your Timezone.
var info = TimeZoneInfo.FindSystemTimeZoneById("Greenwich Standard Time");
DateTimeOffset localServerTime = DateTimeOffset.Now;
bool isDaylightSaving = info.IsDaylightSavingTime(localServerTime);
There are further examples here
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