Link to home
Start Free TrialLog in
Avatar of gromul
gromul

asked on

Batch script: creating a time stamp

I need a small batch script that would create a time stamp based on the current time in this format: YYYYMMDDHHmmSS. Y is for year, M for month, m for minute, etc. Can anyone help me with this? Some sample code to get me started would be helpful.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The seconds are gonna be difficult, since 'time /t' does not output them. You could use

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

for /F "tokens=1,2,3,4 delims=:. " %%i in ('time /t') do set t=%%i%%j%%k%%l

set timestamp=%d%%t%

echo %timestamp%
Avatar of gromul
gromul

ASKER

Thanks!