Convert Unix time with PowerShell

后端 未结 7 1923
南方客
南方客 2020-11-28 14:58

I am parsing an SQLite database using the PowerShell SQLite module, and a couple of the return values are created and modified, both of which are in Unix time.

What

7条回答
  •  醉话见心
    2020-11-28 15:49

    I wanted to be sure that I was calculating from UTC, so I added the SpecifyKind:

    $epochStart = New-Object -Type DateTime -ArgumentList 1970, 1, 1, 0, 0, 0, 0
    $epochStart = [DateTime]::SpecifyKind($epochStart,[DateTimeKind]::Utc)
    
    $DateTimeUTC = $epochStart.AddSeconds($UnixTimestamp)
    

提交回复
热议问题