Created
April 5, 2018 17:05
-
-
Save jaredcatkinson/af352bb42afca7138fafd0bc9b3eb788 to your computer and use it in GitHub Desktop.
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 ConvertFrom-EpochTime | |
{ | |
param | |
( | |
[Parameter(Mandatory = $true)] | |
[Double] | |
$EpochTime | |
) | |
$epochstart = Get-Date -Date 1/1/1970 | |
Write-Output ($epochstart.AddSeconds($EpochTime)) | |
} |
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 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) | |
} |
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
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