Convert-UnixTimestamp
Aus Wiki-WebPerfect
Version vom 26. Februar 2020, 10:07 Uhr von Admin (Diskussion | Beiträge)
-> This function/script is moved to GitHub!
Function Convert-UnixTimestamp { Param( [Parameter(Mandatory=$true)][int64]$udate ) $Timezone = (Get-TimeZone) If ($Timezone.SupportsDaylightSavingTime -eq $True){ $TimeAdjust = ($Timezone.BaseUtcOffset.TotalSeconds + 3600) } Else { $TimeAdjust = ($Timezone.BaseUtcOffset.TotalSeconds) } # Adjust time from UTC to local based on offset that was determined before. $udate = ($udate + $TimeAdjust) # Retrieve start of UNIX Format $orig = (Get-Date -Year 1970 -Month 1 -Day 1 -hour 0 -Minute 0 -Second 0 -Millisecond 0) # Return final time return $orig.AddSeconds($udate) }