直接使用%time:~0,2%在小于10点时,获取到的时间不会自动补零,但是分钟和秒钟会补零,所以小时部分需要自己处理一下。

Code

@echo off
set hour=%time:~0,2%
if %hour% LSS 10 (
set "hour=0%time:~1,1%")
set date=%date:~0,4%-%date:~5,2%-%date:~8,2%T%hour%:%time:~3,2%:%time:~6,5%
echo %date%
pause

Output

2021-04-08T09:45:01.11

Dapper is a simple object mapper for .NET and owns the title of King of Micro ORM in terms of speed and is virtually as fast as using a raw ADO.NET data reader. An ORM is an Object Relational Mapper, which is responsible for mapping between database and programming language.

阅读全文