How to tell if it's British Summer Time

Mark

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?

Adrian Sanguineti

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

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Date is incorrectly showing as British Summer Time

分類Dev

How to find out if it's summer or winter time?

分類Dev

How to tell if expression is evaluated at compile time or runtime?

分類Dev

How to tell if a UITableView's cell is visible on the screen

分類Dev

How do I tell the `date` command to only show the time?

分類Dev

How to tell if two dates are equal while ignoring time?

分類Dev

how to tell rsync to preserve time stamp on files when source tree has a mounted point

分類Dev

How do I tell Prometheus' Alertmanager to send email through Gmail's SMTP server

分類Dev

How to tell bitbake to calculate variable's basehash value after specific task?

分類Dev

How can I monitor the device's audio output to be able to tell if sound is coming out of the speakers/headphone jack?

分類Dev

How to tell if the server socket is not available?

分類Dev

How to tell Hibernate to use a proxy?

分類Dev

How to tell the Renderer that an ConversionException occured?

分類Dev

How to log a method's execution time exactly in milliseconds?

分類Dev

How to use mapGetters with modules and root's getters at the same time?

分類Dev

How do I grab a process's start time in minutes?

分類Dev

How to increase Server-Sent Event's reopen time?

分類Dev

How to pass today's date and time as argument in ansible

分類Dev

How to use the program's exit status at compile time?

分類Dev

How to open form 2nd time when it's closed

分類Dev

How to limit a thread's execution time and terminate it if it runs too long?

分類Dev

How to tell why a cookie is not being sent?

分類Dev

Angular 2: How to tell SystemJS to use a bundle?

分類Dev

How to tell Symfony 3 to ignore certain annotations?

分類Dev

How to tell Angular not to compile some part of template?

分類Dev

How to tell if code needs to be run on the UI thread

分類Dev

How to tell postMessage structured clone to ignore properties?

分類Dev

How to tell MVVMLight create a new view model?

分類Dev

How to tell to VSCode the type of a function parameter (Javascript)

Related 関連記事

  1. 1

    Date is incorrectly showing as British Summer Time

  2. 2

    How to find out if it's summer or winter time?

  3. 3

    How to tell if expression is evaluated at compile time or runtime?

  4. 4

    How to tell if a UITableView's cell is visible on the screen

  5. 5

    How do I tell the `date` command to only show the time?

  6. 6

    How to tell if two dates are equal while ignoring time?

  7. 7

    how to tell rsync to preserve time stamp on files when source tree has a mounted point

  8. 8

    How do I tell Prometheus' Alertmanager to send email through Gmail's SMTP server

  9. 9

    How to tell bitbake to calculate variable's basehash value after specific task?

  10. 10

    How can I monitor the device's audio output to be able to tell if sound is coming out of the speakers/headphone jack?

  11. 11

    How to tell if the server socket is not available?

  12. 12

    How to tell Hibernate to use a proxy?

  13. 13

    How to tell the Renderer that an ConversionException occured?

  14. 14

    How to log a method's execution time exactly in milliseconds?

  15. 15

    How to use mapGetters with modules and root's getters at the same time?

  16. 16

    How do I grab a process's start time in minutes?

  17. 17

    How to increase Server-Sent Event's reopen time?

  18. 18

    How to pass today's date and time as argument in ansible

  19. 19

    How to use the program's exit status at compile time?

  20. 20

    How to open form 2nd time when it's closed

  21. 21

    How to limit a thread's execution time and terminate it if it runs too long?

  22. 22

    How to tell why a cookie is not being sent?

  23. 23

    Angular 2: How to tell SystemJS to use a bundle?

  24. 24

    How to tell Symfony 3 to ignore certain annotations?

  25. 25

    How to tell Angular not to compile some part of template?

  26. 26

    How to tell if code needs to be run on the UI thread

  27. 27

    How to tell postMessage structured clone to ignore properties?

  28. 28

    How to tell MVVMLight create a new view model?

  29. 29

    How to tell to VSCode the type of a function parameter (Javascript)

ホットタグ

アーカイブ