Windows 11 - Batch Get DateTime year, month, day, hour, min, sec (04-feb-2025)


Get year, month, day, hour, min and sec inside a batch file.
WMIC is not part of Windows 11 anymore, so this powershell command will do the trick.

Create a BAT file to use this commands:
@echo off

REM DATETIME
for /f "tokens=*" %%x in ('powershell -NoLogo -NonInteractive -OutputFormat Text -Command "[DateTime]::Now.ToString(\"yyyy-MM-dd HH:mm:ss\")"') do set datetime=%%x
set year=%datetime:~0,4%
set month=%datetime:~5,2%
set day=%datetime:~8,2%
set hour=%datetime:~11,2%
set min=%datetime:~14,2%
set sec=%datetime:~17,2%
Output : 2025-02-04 23:00:18


Bekijk meer nieuws >>