Created
December 11, 2017 13:58
-
-
Save f100024/12a3a574c459eae78a674bc2d772ba02 to your computer and use it in GitHub Desktop.
Windows batch file date stamp
This file contains hidden or 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
| :: | |
| :: Thanks to: https://stackoverflow.com/questions/19832669/inserting-date-time-stamp-in-file-name-using-bat-script/19835038#19835038 | |
| :: | |
| @echo off | |
| for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" | |
| set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" | |
| set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" | |
| set "datestamp=%YYYY%%MM%%DD%" & set "timestamp=%HH%%Min%%Sec%" | |
| set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%" | |
| echo datestamp: "%datestamp%" | |
| echo timestamp: "%timestamp%" | |
| echo fullstamp: "%fullstamp%" | |
| pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment