I recently went down the rabbit hole working with PowerShell, datetime and time zone calculations. Here are some of the things that I learned: Use [datetimeoffset] instead of [datetime]. [datetimeoffset] has the daylight savings offset as part of the object. Example: [datetimeoffset]$ThisDate = Get-Date -Year 2007 -Month 3 -Day 10 -Hour 0 -Minute 0 -Second…
Tag: DateTime
Is that String a Date?
Test-IsDate is a simple function which tests a string to determine whether it is a date. function Test-IsDate([string]$sDate) { [boolean]($sDate -as [DateTime]) } Test-IsDate ‘Monday, August 13, 2018 1:28:48 PM’ returns True.