Skip to content

Instantly share code, notes, and snippets.

@gitfvb
Last active March 15, 2023 12:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gitfvb/9d6e0f973a57d6caee96f29bf7a2d268 to your computer and use it in GitHub Desktop.
Save gitfvb/9d6e0f973a57d6caee96f29bf7a2d268 to your computer and use it in GitHub Desktop.
powershell get utc datetime
# 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")
[datetime]::UtcNow.ToString("o")
[datetime]::UtcNow.ToString("yyyyMMddHHmmss")
[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