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
  • 37,241
  • 25
  • 195
  • 267
Eduard Florinescu
  • 16,747
  • 28
  • 113
  • 179

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
  • 55,367
  • 18
  • 148
  • 187