Infra_HDC icon

Leading Zeros In A Batch Timestamp

Infra_HDC | PRO | 03/20/18 01:24:42 PM UTC | 0 ⭐ | 866 👁️ | Never ⏰ | []
Batch |

390 B

|

None

|

0 👍

/

0 👎

:prepare time stamp
set year=%date:~10,4%
set month=%date:~4,2%
set day=%date:~7,2%
set hour=%time:~0,2%
:replace leading space with 0 for hours < 10
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
set minute=%time:~3,2%
set second=%time:~6,2%
set timeStamp=%year%_%month%_%day%_%hour%_%minute%_%second%
 
rem Proof: https://www.ezrasf.com/wplog/2014/01/23/leading-zeros-in-a-batch-timestamp/

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎