Skip to content

Instantly share code, notes, and snippets.

@cjwinchester
Created April 9, 2015 05:37
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cjwinchester/64a921d1190aefb8eae1 to your computer and use it in GitHub Desktop.
Save cjwinchester/64a921d1190aefb8eae1 to your computer and use it in GitHub Desktop.
Get today's date in YYYY-MM-DD format in a Windows batch file.
:: adapted from http://stackoverflow.com/a/10945887/1810071
@echo off
for /f "skip=1" %%x in ('wmic os get localdatetime') do if not defined MyDate set MyDate=%%x
for /f %%x in ('wmic path win32_localtime get /format:list ^| findstr "="') do set %%x
set fmonth=00%Month%
set fday=00%Day%
set today=%Year%-%fmonth:~-2%-%fday:~-2%
echo %today%
@korenevskiy
Copy link

Good. Cool !

@mbraz
Copy link

mbraz commented Jan 29, 2022

thanks!

@Nicklas373
Copy link

Thanks!

@swdreams
Copy link

Thanks!

@korenevskiy
Copy link

string cd /d "%~dp0"
for set current path file bat as current path execute program

@cpuwolf
Copy link

cpuwolf commented Jul 25, 2023

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment