How can I find the time in milliseconds using PowerShell?
You can get the full date with milliseconds with the following:
Get-Date -Format HH:mm:ss.fff
The question suggests finding a given datetime in milliseconds (Microsoft epoch time). This is easily solved with:
[Math]::Round((Get-Date).ToFileTime()/10000)
or
[Math]::Round((Get-Date).ToFileTimeUTC()/10000)
To convert this to Unix epoch time in seconds:
[Math]::Round((Get-Date).ToFileTime() / 10000000 - 11644473600)
Where 11644473600 is the number of elapsed seconds between the Microsoft epoch (January 1, 1601 A.D. (C.E.)) and the Unix epoch (January 1, 1970, 12AM UTC/GMT)
https://msdn.microsoft.com/en-us/library/system.datetime.tofiletime(v=vs.110).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With