Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if it's British Summer Time

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?

like image 468
Mark Avatar asked Oct 22 '14 11:10

Mark


People also ask

Is UK now BST or GMT?

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.

What months are British Summer Time?

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.

Is BST and GMT the same?

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.

Why do they call it British Summer Time?

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.


1 Answers

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

like image 106
Adrian Sanguineti Avatar answered Sep 23 '22 02:09

Adrian Sanguineti