[PowerShell] NetApp WFA Job Execution Uses UNIX Time Date * 1000 (milliseconds)

Similar to this blog post:
http://examcramnotes.blogspot.com/2020/06/netapp-oci-uses-unix-time-date.html

WFA Job Execution also uses UNIX time date. Actually it uses UNIX time date * 1000 (i.e. milliseconds).

$epoc = Get-Date -Date "01/01/1970"

If $Start is in the PowerShell [System.DateTime] type:

PS> $start.gettype()

Is Public IsSerial Name     BaseType
--------- -------- ----     --------
True      True     DateTime System.ValueType

To convert $Start into UNIX Time Date and milliseconds:

$start_time = [math]::Round((New-TimeSpan -Start $epoc -End (Get-Date -Date $Start)).TotalSeconds * 1000)

If you want from the start of time:

$start_time = 0

If you want $end to be now:

$end = Get-Date

And in UNIX Time Date milliseconds this is:

$end_time = [math]::Round((New-TimeSpan -Start $epoc -End (Get-Date -Date $end)).TotalSeconds * 1000)

If you want the UNIX Time Date in seconds for say 1 Jan 9999 (you'll need to * 1000 for WFA):

PS> $Future_Date = Get-Date "Jan 1,9999"
PS> $future_time = [math]::Round((New-TimeSpan -Start $epoc -End (Get-Date -Date $Future_Date)).TotalSeconds)
PS> $future_time

253370764800

Note: Two of the examples above have * 1000 because we need to use milliseconds in WFA. The final example I thought I'd just show seconds.

Image: Using UNIX Time Stamp Converter to Verify UNIX Time Date

Comments