Reply to Message

View discussion in a popup

Replying to:
LucD
Leadership
Leadership

The difference in length is due to the base you are using.

With UFormat '%s' you are calculating "Seconds elapsed since January 1, 1970 00:00:00"

But you need nanoseconds, hence the longer number.

The following show the 2 methods.

$now = Get-Date

(Get-Date -Date $now -UFormat '%s').Replace((Get-Culture).NumberFormat.NumberDecimalSeparator,'')

$unixEpochStart = New-Object DateTime 1970,1,1,0,0,0,([DateTimeKind]::Utc)

[int64]((([datetime]$now) - $unixEpochStart).TotalMilliseconds*1000000)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos