CMD下获取系统时间戳字符串

set year=%date:~,4%
set mon=%date:~5,2%
set day=%date:~8,2%
set hh=%time:~0,2%
set mm=%time:~3,2%
set ss=%time:~6,2%
set timestamp1=%year%%mon%%day%_%hh%%mm%%ss%
@rem replace space with zero.
@注意上面获取的系统时间/日期可能有空格,所以要使用字符0来替换空格符
set timestamp=%timestamp1: =0%
@ren 后面的就直接使用 %timestamp% 了

 

posted @ 2024-01-20 09:15  -ssdq-  阅读(260)  评论(0编辑  收藏  举报