Convert-UnixTimestamp: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „<source lang="powershell"> Function Convert-UnixTimestamp { Param( [Parameter(Mandatory=$true)][int64]$udate ) $Timezone = (Get-TimeZon…“) |
Admin (Diskussion | Beiträge) |
||
Zeile 1: | Zeile 1: | ||
+ | <span style="font-size:20px;"><span style="color:red">'''-> This function/script is moved to [https://github.com/R-Studio/PSTools GitHub]!'''</span></span><br> | ||
+ | |||
<source lang="powershell"> | <source lang="powershell"> | ||
Function Convert-UnixTimestamp { | Function Convert-UnixTimestamp { | ||
− | |||
Param( | Param( | ||
[Parameter(Mandatory=$true)][int64]$udate | [Parameter(Mandatory=$true)][int64]$udate |
Aktuelle Version vom 26. Februar 2020, 10:07 Uhr
-> 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) }