Private/ConvertTo-UNIXTime.ps1

1
2
3
4
5
6
7
8
9
function ConvertTo-UNIXTime {
    # https://gradualdev.wordpress.com/2014/01/21/converting-from-unix-timestamp/
    Param (
        [datetime]$Date
    )

    $epoch = [timezone]::CurrentTimeZone.ToLocalTime([datetime]'1/1/1970')
    (New-TimeSpan -Start $epoch -End $Date).TotalSeconds
}