Last active
January 3, 2025 19:27
-
-
Save rossnz/8519986 to your computer and use it in GitHub Desktop.
Convert a DateTime object to Unix timestamp in PowerShell
This file contains hidden or 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
Function Convert-ToUnixDate ($PSdate) { | |
$epoch = [timezone]::CurrentTimeZone.ToLocalTime([datetime]'1/1/1970') | |
(New-TimeSpan -Start $epoch -End $PSdate).TotalSeconds | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment