Creating a DateTime object with a specific UTC DateTime in PowerShell

前端 未结 6 1161
野趣味
野趣味 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:40

    This is how it works in .NET, right? PowerShell just calls the ToUniversalTime method. From http://msdn.microsoft.com/en-us/library/system.datetime.touniversaltime.aspx

    The Coordinated Universal Time (UTC) is equal to the local time minus the 
    UTC offset. For more information about the UTC offset, see TimeZone.GetUtcOffset.
    The conversion also takes into account the daylight saving time rule that applies 
    to the time represented by the current DateTime object. 
    

提交回复
热议问题