Last active
March 15, 2023 12:58
-
-
Save gitfvb/9d6e0f973a57d6caee96f29bf7a2d268 to your computer and use it in GitHub Desktop.
powershell get utc datetime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Older style, with better compatibility | |
$timestampTwo = Get-Date -Format "yyyyMMddHHmmss" | |
$timestampTwoUTC = (Get-Date).ToUniversalTime().ToString("yyyyMMddHHmmss") | |
# Newer style, but not always compatible | |
$timestampOne = [datetime]::Now.ToString("yyyyMMddHHmmss") | |
$timestampOneUTC = [datetime]::UtcNow.ToString("yyyyMMddHHmmss") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[datetime]::UtcNow.ToString("o") | |
[datetime]::UtcNow.ToString("yyyyMMddHHmmss") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[datetime]::ParseExact("20181227132116", "yyyyMMddHHmmss", $null) | |
[datetime]::ParseExact("20181227132116", "yyyyMMddHHmmss", [Globalization.CultureInfo]::CreateSpecificCulture('de-DE')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment