Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- rem System provided date and time
- echo %DATE%
- echo %TIME%
- rem Capture Hour
- set hour=%time:~0,2%
- rem Remove leading space if single digit
- if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
- echo hour=%hour%
- rem Minutes
- set min=%time:~3,2%
- rem Remove leading space
- if "%min:~0,1%" == " " set min=0%min:~1,1%
- echo min=%min%
- rem Seconds
- set secs=%time:~6,2%
- rem Remove leading space
- if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
- echo secs=%secs%
- rem Year
- set year=%date:~-4%
- echo year=%year%
- rem Month
- set month=%date:~3,2%
- rem Remove leading space if single digit
- if "%month:~0,1%" == " " set month=0%month:~1,1%
- echo month=%month%
- rem Day
- set day=%date:~0,2%
- rem Remove leading space
- if "%day:~0,1%" == " " set day=0%day:~1,1%
- echo day=%day%
- rem Reformatted date
- set datetimef=%year%-%month%-%day% %hour%-%min%-%secs%
- echo datetimef=%datetimef%
- pause
Add Comment
Please, Sign In to add comment