Skip to content

Instantly share code, notes, and snippets.

@austoonz
Last active June 1, 2021 15:47
Embed
What would you like to do?
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