Creating a DateTime object with a specific UTC DateTime in PowerShell

前端 未结 6 1167
野趣味
野趣味 2021-02-02 07:23

I\'m trying to create a DateTime object with a specific UTC timestamp in PowerShell. What\'s the simplest way to do this?

I tried:

Get-Date
         


        
6条回答
  •  南方客
    南方客 (楼主)
    2021-02-02 07:47

    $utctime = New-Object DateTime 1970, 1, 1, 0, 0, 0, ([DateTimeKind]::Utc)
    

    If you print out $utctime, then you get:

    1. januar 1970 00:00:00
    

    Also, $utctime.Kind is correctly set to Utc.

提交回复
热议问题