Skip to content

Instantly share code, notes, and snippets.

@shunwen
Created July 23, 2012 07:03
Show Gist options
  • Save shunwen/3162357 to your computer and use it in GitHub Desktop.
Save shunwen/3162357 to your computer and use it in GitHub Desktop.
Chop %date% and %time% into useful tokens
REM get date from MM/DD/YYYY
SET YEAR=%DATE:~6,4%
SET MONTH=%DATE:~0,2%
SET DAY=%DATE:~3,2%
SET DATENOW=%YEAR%%MONTH%%DAY%
REM get time from hh:mm:ss.ss
SET hh=%TIME:~0,2%
IF %hh% LSS 10 SET hh=0%hh:~1,1%
SET mm=%TIME:~3,2%
SET ss=%TIME:~6,2%
SET TIMENOW=%hh%%mm%%ss%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment