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
You can use the SpecifyKind method:
PS C:\IT\s3> $timestamp
Wednesday, July 18, 2018 7:57:14 PM
PS C:\IT\s3> $timestamp.kind
Unspecified
PS C:\IT\s3> $utctimestamp = [DateTime]::SpecifyKind($timestamp,[DateTimeKind]::Utc)
PS C:\IT\s3> $utctimestamp
Wednesday, July 18, 2018 7:57:14 PM
PS C:\IT\s3> $utctimestamp.kind
Utc