Skip to content

Instantly share code, notes, and snippets.

@austoonz
Last active June 1, 2021 15:47
Show Gist options
  • Save austoonz/3b7d39f618f1eeb206c24faf9454227a to your computer and use it in GitHub Desktop.
Save austoonz/3b7d39f618f1eeb206c24faf9454227a to your computer and use it in GitHub Desktop.
PowerShell snippets for dealing with epoch ('01-01-1970')
function Get-EpochTimeFrom {
param (
[int]$Seconds
)
(Get-Date -Date '01-01-1970') + ([System.TimeSpan]::FromSeconds($Seconds))
}
function Get-EpochTimeInSeconds
{
param
(
[DateTime] $DateTime
)
if ($DateTime)
{
([DateTimeOFfset]$Date).ToUnixTimeSeconds()
}
else
{
[DateTimeOffset]::Now.ToUnixTimeSeconds()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment