how to get current date and time in command line
- by Ieyasu Sawada
I am using mysqldump to backup mysql database. Now I just need to use the current date and time as file name for the generated sql file. How do I do that if my current code looks like this:
mysqldump -u root -p --add-drop-table --create-options --password= onstor >c:\sql.sql
I also found this code from this site, but I do not know how to incorporate it in my current code:
@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
echo %mydate%_%mytime%
Please help, thanks:)