How do I get the day month and year from a Windows cmd.exe script?

前端 未结 14 1385
长情又很酷
长情又很酷 2020-12-23 17:02

How do I get the current day month and year from inside a Windows cmd script? I need to get each value into a separate variable.

14条回答
  •  臣服心动
    2020-12-23 17:08

    echo %Date:~7,2% gets current day
    

    7 is starting position 2 number of digits to display

    echo %Date:~7,2% gets current day
    
    echo %Date:~4,2% gets current month
    
    echo %Date:~10,4% gets current year
    

提交回复
热议问题