CScript:epoch以来的时间戳,以毫秒为单位?

时间:2013-05-20 11:04:09

标签: batch-file timestamp epoch wsh

自Unix时代以来,我需要以毫秒为单位获得当前的时间戳。

我得到了

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

回答这个问题:

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

但第一个参数不支持"ms"

有没有办法以毫秒为单位获得上述时间戳,使用CScript或可从.bat运行的任何其他方法或作为CScript?

1 个答案:

答案 0 :(得分:1)

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

如果您打算在批处理脚本中使用它,则需要double%

C:\>powershell [float](Get-Date -UFormat %s)*1000
相关问题