Created
July 18, 2017 23:29
-
-
Save gojimmypi/d0864616660434d4ed24b194adf5e433 to your computer and use it in GitHub Desktop.
DOS environment variable formatted date-time as YYMMDD_HHMMSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: set the FileStamp variable to the current date: YYMMDD_HHMMSS | |
:: the simplest method, to use existing TIME ad DATE variables: | |
:: date = Thu 09/17/2015 | |
:: time = 11:13:15.47 | |
:: 012345678901234567890 | |
:: | |
:: There is no leading zero for single digit hours (e.g. 9:00am), so we need to manually include the zero | |
:: here | | |
if "%TIME:~0,1%" == " " set FileStamp=%DATE:~12,2%%DATE:~4,2%%DATE:~7,2%_0%TIME:~1,1%%TIME:~3,2%%TIME:~6,2% | |
:: otherwise, if a space not found before the digit, it is a 2 digit hour, so no extract zero is needed | |
if NOT "%TIME:~0,1%" == " " set FileStamp=%DATE:~12,2%%DATE:~4,2%%DATE:~7,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment