Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date in .bat 1

Status
Not open for further replies.

loloman

Technical User
Oct 30, 2002
16
0
0
FR
how to transform date/t and time/t in .bat

ex : for date : 12/10/2003 in 12102003
for time 12:33:00 in 123300
 
This will give you the date in the format you requested:

for /f "tokens=1-2" %%a in ('date /t') do (
set day=%%a
set date=%%b)

for /f "tokens=1-3 delims=/" %%a in ("%date%") do (
set m=%%a
set d=%%b
set y=%%c)

set date1=%m%%d%%y%

echo %date1%

Note sure about the time though, since "time/t" gives you "12:33P" as the output.

 
------------------
for /F "tokens=1,2,3,4 delims=/ " %%i in ('date/t') do set d=%%i-%%j-%%k

for /F "tokens=1,2 delims=:" %%a in ('time/t') do set t=%%a-%%b

echo %d%
echo %t%
------------------


this is what I use in a batch file to copy and rename files so that they get a date and time stamp.

Jonathan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top