gpt4 book ai didi

windows - 在 Windows cmd 中获取精确到毫秒的系统时间

转载 作者:可可西里 更新时间:2023-11-01 10:43:56 32 4
gpt4 key购买 nike

我试图在 Windows cmd 中将系统时间精确​​到毫秒。我知道可以使用以下方法获得厘秒精度:

echo %time%

我发现其他问题也提出了完全相同的问题,但没有完全回答问题的答案。到目前为止,这是我发现的内容:

此解决方案仅适用于厘秒精度(与我上面描述的相同): Print time in a batch file (milliseconds)

该方案提供了定时器方案,但没有打印当前时间戳方案: Print Batch Time in Milliseconds

如有任何帮助,我们将不胜感激。

最佳答案

正如 Neil 所指出的,cmd 中没有 native 解决方案。对于可以选择使用 PowerShell 的任何人,您可以使用以下命令:

(Get-Date -UFormat "%Y-%m-%d %H:%M:%S").toString() + "." + ((Get-Date).millisecond)

可能有更简洁的方法,但这对我的目的有用。

由于问题被标记为 cmd 从 cmd 调用它的适当命令行是:

powershell -command "(Get-Date -UFormat '%Y-%m-%d %H:%M:%S').toString() + '.' + ((Get-Date).millisecond)"

关于windows - 在 Windows cmd 中获取精确到毫秒的系统时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35871328/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com