windows 获取时间戳
Windows 批处理时间戳
1、时间戳格式:
取年份: echo %date:~0,4% 取月份: echo %date:~5,2% 取日期: echo %date:~8,2% 取星期: echo %date:~10,6% 取小时: echo %time:~0,2% 取分钟: echo %time:~3,2% 取秒: echo %time:~6,2% 取毫秒: echo %time:~9,2%
2、获取年月日
@set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
echo %Ymd%
:: 显示当前年月日
3、获取年月日时分秒
@set "nowtime=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%"
echo %nowtime%
:: 显示当前时间
示例:
:: 移动重命名 123 为时间命名 move 123 123-%nowtime%