rem DOS get current time rem ======================= rem get yyyy/mm/dd set mydate=%DATE:~0,10% echo %mydate% rem ======================= rem get yyyy set yyyy=%DATE:~0,4% echo %yyyy% rem ======================= rem get mm set mm=%DATE:~5,2% echo %mm% rem ======================= rem get dd set dd=%DATE:~8,2% echo %dd% rem ======================= rem get yyyy-mm-dd set curdate=%yyyy%-%mm%-%dd% echo %curdate%
C:\Documents and Settings\Administrator>rem DOS get current timeC:\Documents and Settings\Administrator>rem =======================C:\Documents and Settings\Administrator>rem get yyyy/mm/ddC:\Documents and Settings\Administrator>set mydate=2013-07-22C:\Documents and Settings\Administrator>echo 2013-07-222013-07-22C:\Documents and Settings\Administrator>rem =======================C:\Documents and Settings\Administrator>rem get yyyyC:\Documents and Settings\Administrator>set yyyy=2013C:\Documents and Settings\Administrator>echo 20132013C:\Documents and Settings\Administrator>rem =======================C:\Documents and Settings\Administrator>rem get mmC:\Documents and Settings\Administrator>set mm=07C:\Documents and Settings\Administrator>echo 0707C:\Documents and Settings\Administrator>rem =======================C:\Documents and Settings\Administrator>rem get ddC:\Documents and Settings\Administrator>set dd=22C:\Documents and Settings\Administrator>echo 2222C:\Documents and Settings\Administrator>rem =======================C:\Documents and Settings\Administrator>rem get yyyy-mm-ddC:\Documents and Settings\Administrator>set curdate=2013 -07 -22C:\Documents and Settings\Administrator>echo 2013 -07 -222013 -07 -22C:\Documents and Settings\Administrator>