Skip to content

Instantly share code, notes, and snippets.

@jaredcatkinson
Created April 5, 2018 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jaredcatkinson/af352bb42afca7138fafd0bc9b3eb788 to your computer and use it in GitHub Desktop.
Save jaredcatkinson/af352bb42afca7138fafd0bc9b3eb788 to your computer and use it in GitHub Desktop.
function ConvertFrom-EpochTime
{
param
(
[Parameter(Mandatory = $true)]
[Double]
$EpochTime
)
$epochstart = Get-Date -Date 1/1/1970
Write-Output ($epochstart.AddSeconds($EpochTime))
}
function ConvertTo-EpochTime
{
param
(
[Parameter()]
[DateTime]
$Timestamp
)
if(-not $PSBoundParameters.ContainsKey('Timestamp'))
{
$Timestamp = Get-Date
}
$epochstart = Get-Date -Date 1/1/1970
Write-Output (($Timestamp - $epochstart).TotalSeconds)
}
Two scripts to convert to and from Epoch Time.
Epoch Time is the number of seconds since January 1st 1970.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment