1

I need to get the current time-stamp in milli-seconds since the Unix epoch.

I got

WScript.Echo DateDiff("s", "01/01/1970 00:00:00", Now())

from answer to this question:

Is there a way to get epoch time using a Windows command?

but it doesn't support "ms" for the first parameter.

Is there a way to get the above mentioned timestamp in millisecond, using CScript or any other method runnable from .bat or as a CScript?

Cœur
  • 34,719
  • 24
  • 185
  • 251
Eduard Florinescu
  • 15,293
  • 28
  • 107
  • 170

1 Answers1

1
C:\>for /f "tokens=1,2 delims=.," %a in ('powershell Get-Date -UFormat %s') do echo %a%b

if you intend to use this in batch script you'll need double %

or

C:\>powershell [float](Get-Date -UFormat %s)*1000
npocmaka
  • 53,069
  • 18
  • 138
  • 177