Determine Daylight Savings status for different time zone in Powershell

后端 未结 3 2056
南笙
南笙 2021-01-14 10:17

Is there a slick way in PowerShell to ascertain if a past date in another time zone is Daylight Savings or not? Here is the situation, our database is in Europe and the tim

3条回答
  •  心在旅途
    2021-01-14 10:33

    Cole, I love the inspiration as your response was a needle in a haystick and just what I needed. However, it produced an error. After some messing around, I got the following to work:

    $isDST = ([System.TimeZoneInfo]::ConvertTimeFromUtc((Get-Date).ToUniversalTime(), [System.TimeZoneInfo]::FindSystemTimeZoneById("Central Standard Time"))).IsDaylightSavingTime()
    

    (in PowerShell v4)

提交回复
热议问题