BigMan said:
How can I set a variable to today's date in the format yyyy.mm.dd
regardless of regional settings?
Hi
A combined batch/vbs solution creating a date variable in the
format YYYY.MM.DD regardless of the regional settings:
'--------------------8<----------------------
@echo off
echo D = Now : WScript.Echo Year(D) ^& "." ^& _ >%tmp%\today.vbs
echo Right(100+Month(D),2) ^& "." ^& Right(100+Day(D),2) >>%tmp%\today.vbs
for /f "tokens=1" %%a in (
'cscript.exe //Nologo %tmp%\today.vbs') do set today=%%a
del %tmp%\today.vbs
echo Todays date: %today%
'--------------------8<----------------------
Any reason you use . as separator?
If you look at the ISO 8601 standard, the preferred date field
separator is '-' (YYYYMMDD is also ISO compliant).
More about ISO 8601 here:
http://www.merlyn.demon.co.uk/datefmts.htm#Writ
http://www.cl.cam.ac.uk/~mgk25/iso-time.html
http://www.iso.org/iso/en/prods-services/popstds/datesandtime.html