Batch file 将系统日期转换为dd/mm/yyyy

Batch file 将系统日期转换为dd/mm/yyyy,batch-file,Batch File,在我提出问题之前,让我告诉你我是批处理文件的新手 我有一个要求,我想将系统日期转换为DD/MM/YYYY格式,有人能帮我吗?这就可以了 我尝试过以下代码:对于/F“TOKENS=1,2 DELIMS=/eol=/”%A IN('DATE/T')DO SET mm=%B FOR/F“TOKENS=1,2 DELIMS=/eol=/”%A IN('echo%CDATE%')DO SET dd=%B FOR/F“TOKENS=2,3 DELIMS=/”%A IN('echo%CDATE%'))DO

在我提出问题之前,让我告诉你我是批处理文件的新手


我有一个要求,我想将系统日期转换为DD/MM/YYYY格式,有人能帮我吗?

这就可以了


我尝试过以下代码:对于/F“TOKENS=1,2 DELIMS=/eol=/”%A IN('DATE/T')DO SET mm=%B FOR/F“TOKENS=1,2 DELIMS=/eol=/”%A IN('echo%CDATE%')DO SET dd=%B FOR/F“TOKENS=2,3 DELIMS=/”%A IN('echo%CDATE%'))DO SET yyyyy=%B如果我的系统日期是2013年2月21日,我的输出结果是2013年2月21日。Date和monthPerhaps后面会有一个额外的空格。在每种情况下,空格都位于
SET
语句中
%%B
之后。使用如下双引号:
设置“mm=%%B”
@echo off
call :GetDate year month day
echo/Today is: %day%-%month%-%year%
goto :EOF

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:GetDate yy mm dd
::
:: By:   Ritchie Lawrence, 2002-06-15. Version 1.0
::
:: Func: Loads local system date components into args 1 to 3. For NT4/2K/XP
::
:: Args: %1 var to receive year, 4 digits (by ref)
::       %2 var to receive month, 2 digits, 01 to 12 (by ref)
::       %3 Var to receive day of month, 2 digits, 01 to 31 (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS
set t=2&if "%date%z" LSS "A" set t=1
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo/^|date') do (
  for /f "tokens=%t%-4 delims=.-/ " %%d in ('date/t') do (
    set %%a=%%d&set %%b=%%e&set %%c=%%f))
endlocal&set %1=%yy%&set %2=%mm%&set %3=%dd%&goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::