I have the following code
set x=%date /T %
date 16/12/2012
date 15/12/2012
some stuff goes here
echo set your date
date %x% <--- getting error in that line.
pause
So how can i get the date in the format dd/mm/yy
I have the following code
set x=%date /T %
date 16/12/2012
date 15/12/2012
some stuff goes here
echo set your date
date %x% <--- getting error in that line.
pause
So how can i get the date in the format dd/mm/yy
Two more ways that do not depend on the time settings (both taken from :How get data/time independent from localization:).And both also get the day of the week and none of them requires admin permissions!:
1.MAKECAB - will work on EVERY windows system (fast but creates a small temp file ) (the foxidrive script):
2. ROBOCOPY - it's not native command for windows xp and win 2003 but can be downloaded from microsoft site .But is built-in in everything from Vista and above:
And three more ways that uses other windows script languages.They will give you more flexibility e.g. you can get week of the year, time in milliseconds and so on.
3.JSCRIPT/BATCH hybrid (need to be saved as
.bat
).Jscript is available on every system form NT and above , as a part of windows script host (though can be disabled through the registry it's a rare case):4.VSCRIPT/BATCH hybrid (Is it possible to embed and execute VBScript within a batch file without using a temporary file?) same case as jscript , but hybridization is not so perfect:
5.POWERSHELL - can be installed on every machine that has .net - download from Microsoft (v1 , v2 , v3 (only for win7 and above)).Installed by default on everything form Win7/Win2008 and above :
6.Self-compiled jscript.net/batch (never seen a windows machine without .net so I think this is a pretty portable):
7.Logman This cannot get the year and day of the week.It's comparatively slow , also creates a temp file and is based on the time stamps that logman puts on its log files.Will work everything from XP and above.Probably will be never used by anybody - including me - but is one more way...
more information about get-date function.
You can get the date format of dd/mm/yy by using
wmic
command. This command allows you to get current date without getting affected by regional settings.You can save it as
date.bat
and run this batch file by executing the following in command prompt:Hope this helps.