我知道,可以使用@echo % time %打印批处理时间,直到厘米秒。有没有一种方法可以获得毫秒的精度为3,并以小时为零?电子邮件06:58:30.483
%时间%打印,不带前导零,以小时表示,在毫秒内打印2个分数,例如: 6:58:25.25
发布于 2022-03-18 19:18:02
因为我假设它比威麦克或powershell快得多,下面是一个带有vbscript wsh助手的批文件:
<!-- ::Script Language="Batch"
@For /F %%G In ('%SystemRoot%\System32\cscript.exe //NoLogo "%~f0?.wsf"')Do @Echo(%%G
@Pause&Exit /B
-->
<Job><Script Language="VBScript">
t0 = Timer : t1 = Int(t0) : ms = Int((t0 - t1) * 1000) : s = t1 mod 60
t1 = Int(t1 / 60) : m = t1 mod 60 : h = Int(t1 / 60)
strT = String(2 - Len(h), "0") & h & ":"
strT = strT & String(2 - Len(m), "0") & m & ":"
strT = strT & String(2 - Len(s), "0") & s & "."
strT = strT & String(3 - Len(ms), "0") & ms
WScript.Echo strT</Script></Job>发布于 2022-03-18 17:59:05
如果您是在受支持的windows系统上,那么您已经有了一个程序,它将使用在cmd下运行的batch-file生成所需的内容。
FOR /F "delims=" %%A IN ('powershell.exe -NoLogo -NoProfile -Command "Get-Date -Format HH:mm:ss.fff"') DO (SET "THETIME=%%~A")
ECHO THETIME is %THETIME%https://stackoverflow.com/questions/71530189
复制相似问题