Dos Batch – Extract Time for Logging
Easy way to extract the date and time for logging.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
@echo off cls rem Parse Date [19.08.2011] rem It needs to be adjustet to your time !!! set cur_yyyy=%date:~6,4% set cur_mm=%date:~3,2% set cur_dd=%date:~0,2% rem Parse Time [ 9:04:34.89] set cur_hh=%time:~0,2% if %cur_hh% lss 10 (set cur_hh=0%time:~1,1%) set cur_nn=%time:~3,2% set cur_ss=%time:~6,2% set cur_ms=%time:~9,2% rem Time Stamp Format set timestamp=%cur_yyyy%%cur_mm%%cur_dd%_%cur_hh%%cur_nn%%cur_ss% echo %timestamp% |