windows - date格式 - cmd時間




如何在Windows命令行上獲取當前的日期時間,以適合的格式在文件名中使用? (18)

更新:現在是2016年,我會使用PowerShell進行此操作,除非有非常令人信服的向後兼容原因,特別是因為使用date的區域設置問題。 請參閱@ npocmaka的https://stackoverflow.com/a/19799236/8479

什麼是Windows命令行語句我可以使用什麼格式來獲取當前日期時間,我可以將它放入文件名?

我想要一個.bat文件,將當前日期和時間作為名稱的一部分壓縮到一個存檔中,例如Code_2008-10-14_2257.zip 。 有沒有簡單的方法可以做到這一點,獨立於機器的區域設置?

我真的不介意日期格式,理想情況下它會是yyyy-mm-dd,但任何簡單的事情都可以。

到目前為止,我已經得到了這個,在我的機器上給了我Tue_10_14_2008_230050_91

rem Get the datetime in a format that can go in a filename.
set _my_datetime=%date%_%time%
set _my_datetime=%_my_datetime: =_%
set _my_datetime=%_my_datetime::=%
set _my_datetime=%_my_datetime:/=_%
set _my_datetime=%_my_datetime:.=_%

rem Now use the timestamp by in a new ZIP file name.
"d:\Program Files\7-Zip\7z.exe" a -r Code_%_my_datetime%.zip Code

我可以忍受這一點,但它似乎有點笨重。 理想情況下,它會更簡短,並具有前面提到的格式。

我正在使用Windows Server 2003和Windows XP Professional。 我不想安裝額外的實用程序來實現這一點(雖然我意識到有一些會做好日期格式)。


區域獨立的日期時間解析

%DATE%dir命令的輸出格式是區域相關的,因此既不健壯也不智能。 date.exeUnxUtils一部分)以任何可想像的格式提供任何日期和時間信息。 您也可以使用date.exe從任何文件中提取日期/時間信息。

示例:(在cmd腳本中使用%%而不是%)

date.exe +"%Y-%m-%d"
2009-12-22

date.exe +"%T"
18時55分03秒

date.exe +"%Y%m%d %H%M%S: Any text"
20091222 185503:任何文字

date.exe +"Text: %y/%m/%d-any text-%H.%M"
文本:09/12 / 22-任何文本-18.55

Command: date.exe +"%m-%d """%H %M %S """"
07-22“18:55:03”`

來自參考文件的日期/時間信息:
date.exe -rc:\file.txt +"The timestamp of file.txt is: %Y-%m-%d %H:%M:%S"

在CMD腳本中使用它獲取年,月,日,時間信息:

for /f "tokens=1,2,3,4,5,6* delims=," %%i in ('C:\Tools\etc\date.exe +"%%y,%%m,%%d,%%H,%%M,%%S"') do set yy=%%i& set mo=%%j& set dd=%%k& set hh=%%l& set mm=%%m& set ss=%%n

在CMD腳本中使用它獲取任何所需格式的時間戳:

for /f "tokens=*" %%i in ('C:\Tools\etc\date.exe +"%%y-%%m-%%d %%H:%%M:%%S"') do set timestamp=%%i

從任何參考文件中提取日期/時間信息。

for /f "tokens=1,2,3,4,5,6* delims=," %%i in ('C:\Tools\etc\date.exe -r file.txt +"%%y,%%m,%%d,%%H,%%M,%%S"') do set yy=%%i& set mo=%%j& set dd=%%k& set hh=%%l& set mm=%%m& set ss=%%n

向文件添加日期/時間信息:

for /f "tokens=*" %%i in ('C:\Tools\etc\date.exe -r file.txt +"%%y-%%m-%%d.%%H%%M%%S"') do ren file.txt file.%%i.txt

date.exe是不需要安裝date.exe

注意:將date.exe複製到搜索路徑中的任何目錄可能會導致其他腳本失敗,並使用Windows內置date命令。


date.exe

Look inside the ZIP file for something called "Date.exe" and rename it "DateFormat.exe" (to avoid conflicts).

Put it in your Windows system32 folder.

It has a lot of "date output" options.

For help, use DateFormat.exe --h

I'm not sure how you would put its output into an environment variable... using SET.


Given a known locality, for reference in functional form. The ECHOTIMESTAMP call shows how to get the timestamp into a variable ( DTS in this example.)

@ECHO off

CALL :ECHOTIMESTAMP
GOTO END

:TIMESTAMP
SETLOCAL  EnableDelayedExpansion
    SET DATESTAMP=!DATE:~10,4!-!DATE:~4,2!-!DATE:~7,2!
    SET TIMESTAMP=!TIME:~0,2!-!TIME:~3,2!-!TIME:~6,2!
    SET DTS=!DATESTAMP: =0!-!TIMESTAMP: =0!
ENDLOCAL & SET "%~1=%DTS%"
GOTO :EOF

:ECHOTIMESTAMP
SETLOCAL
    CALL :TIMESTAMP DTS
    ECHO %DTS%
ENDLOCAL
GOTO :EOF

:END

EXIT /b 0

And saved to file, timestamp.bat, here's the output:


I know that there are numerous ways mentioned already. But here is my way to break it down to understand how it is done. Hopefully, it is helpful for someone who like step by step method.

:: Check your local date format
echo %date%

    :: Output is Mon 08/15/2016

:: get day (start index, number of characters)
::         (index starts with zero)
set myday=%DATE:~0,4%
echo %myday%
    :: output is Mon 

:: get month
set mymonth=%DATE:~4,2%
echo %mymonth%
    :: output is 08

:: get date 
set mydate=%DATE:~7,2% 
echo %mydate%
    :: output is 15

:: get year
set myyear=%DATE:~10,4%
echo %myyear%
    :: output is 2016

With Windows 7, this code works for me:

SET DATE=%date%
SET YEAR=%DATE:~0,4%
SET MONTH=%DATE:~5,2%
SET DAY=%DATE:~8,2%
ECHO %YEAR%
ECHO %MONTH%
ECHO %DAY%

SET DATE_FRM=%YEAR%-%MONTH%-%DAY% 
ECHO %DATE_FRM%

一個基於wmic函數:

:Now  -- Gets the current date and time into separate variables
::    %~1: [out] Year
::    %~2: [out] Month
::    %~3: [out] Day
::    %~4: [out] Hour
::    %~5: [out] Minute
::    %~6: [out] Second
  setlocal
  for /f %%t in ('wmic os get LocalDateTime ^| findstr /b [0-9]') do set T=%%t
  endlocal & (
    if "%~1" neq "" set %~1=%T:~0,4%
    if "%~2" neq "" set %~2=%T:~4,2%
    if "%~3" neq "" set %~3=%T:~6,2%
    if "%~4" neq "" set %~4=%T:~8,2%
    if "%~5" neq "" set %~5=%T:~10,2%
    if "%~6" neq "" set %~6=%T:~12,2%
  )
goto:eof

上行:地區獨立。 缺點:只有系統管理員才能運行wmic.exe。

用法:

call:Now Y M D H N S
echo %Y%-%M%-%D% %H%:%N%:%S%

這迴響了一個像這樣的字符串:

2014-01-22 12:51:53

請注意,函數參數是out參數 - 也就是說,您必須提供變量名稱而不是值。

所有參數都是可選的,所以call:Now YM如果您只想獲得年份和月份, call:Now YM是有效的通話。


以下是一種在單行中獲取日期時間的方法:

for /f "tokens=2,3,4,5,6 usebackq delims=:/ " %a in ('%date% %time%') do echo %c-%a-%b %d%e

在美國這將輸出“yyyy-mm-dd hhmm”。 不同的區域設置會導致不同的%date%輸出,但您可以修改令牌順序。

如果您需要其他格式,請通過重新排列令牌或使用不同(或不)分隔符來修改echo語句。


以下是來自alt.msdos.batch.nt的一個獨立於本地的變體。

把它放在一個文本文件中,例如getDate.cmd

-----------8<------8<------------ snip -- snip ----------8<-------------
    :: Works on any NT/2k machine independent of regional date settings
    @ECHO off
    SETLOCAL ENABLEEXTENSIONS
    if "%date%A" LSS "A" (set toks=1-3) else (set toks=2-4)
    for /f "tokens=2-4 delims=(-)" %%a in ('echo:^|date') do (
      for /f "tokens=%toks% delims=.-/ " %%i in ('date/t') do (
        set '%%a'=%%i
        set '%%b'=%%j
        set '%%c'=%%k))
    if %'yy'% LSS 100 set 'yy'=20%'yy'%
    set Today=%'yy'%-%'mm'%-%'dd'% 
    ENDLOCAL & SET v_year=%'yy'%& SET v_month=%'mm'%& SET v_day=%'dd'%

    ECHO Today is Year: [%V_Year%] Month: [%V_Month%] Day: [%V_Day%]

    :EOF
-----------8<------8<------------ snip -- snip ----------8<-------------

為了讓代碼能夠正常工作,無需將錯誤消息添加到stderr中,我必須為%% a,%% b和%% c添加單引號。 我的語言環境(PT)在循環/解析中的某個階段導致錯誤,例如“set = 20”的內容正在執行。 引號會為賦值語句的左側生成一個令牌(儘管為空)。

缺點是混亂的區域設置變量名稱:'yy','mm'和'dd'。 但是,嘿,誰在乎!


另外兩種不依賴於時間設置的方式(均取自:如何從本地化獲取數據/時間獨立性:) 。 而且兩人都能獲得一周中的哪一天,而且他們都不需要管理員權限!

  1. MAKECAB - 將在每個Windows系統上工作(快速,但創建一個小臨時文件)(foxidrive腳本):

    @echo off
    pushd "%temp%"
    makecab /D RptFileName=~.rpt /D InfFileName=~.inf /f nul >nul
    for /f "tokens=3-7" %%a in ('find /i "makecab"^<~.rpt') do (
       set "current-date=%%e-%%b-%%c"
       set "current-time=%%d"
       set "weekday=%%a"
    )
    del ~.*
    popd
    echo %weekday% %current-date% %current-time%
    pause
    

    有關get-date函數的更多信息

  2. ROBOCOPY - 它不是Windows XP和Windows Server 2003的本地命令,但它可以從Microsoft網站下載 。 但內置於Windows Vista及以上版本的所有內容中:

    @echo off
    setlocal
    for /f "skip=8 tokens=2,3,4,5,6,7,8 delims=: " %%D in ('robocopy /l * \ \ /ns /nc /ndl /nfl /np /njh /XF * /XD *') do (
     set "dow=%%D"
     set "month=%%E"
     set "day=%%F"
     set "HH=%%G"
     set "MM=%%H"
     set "SS=%%I"
     set "year=%%J"
    )
    
    echo Day of the week: %dow%
    echo Day of the month : %day%
    echo Month : %month%
    echo hour : %HH%
    echo minutes : %MM%
    echo seconds : %SS%
    echo year : %year%
    endlocal
    

    還有另外三種使用其他Windows腳本語言的方式。 他們會給你更多的靈活性,例如你可以得到一年的一周,以毫秒為單位的時間等等。

  3. JScript /批量混合(需要保存為.bat )。 作為Windows Script Host的一部分,JScript在每個NT和更高版本的系統上都可用( 儘管可以通過註冊表禁用,但這種情況很少見 ):

    @if (@X)==(@Y) @end /* ---Harmless hybrid line that begins a JScript comment
    
    @echo off
    cscript //E:JScript //nologo "%~f0"
    exit /b 0
    *------------------------------------------------------------------------------*/
    
    function GetCurrentDate() {
            // Today date time which will used to set as default date.
            var todayDate = new Date();
            todayDate = todayDate.getFullYear() + "-" +
                           ("0" + (todayDate.getMonth() + 1)).slice(-2) + "-" +
                           ("0" + todayDate.getDate()).slice(-2) + " " + ("0" + todayDate.getHours()).slice(-2) + ":" +
                           ("0" + todayDate.getMinutes()).slice(-2);
    
            return todayDate;
        }
    
    WScript.Echo(GetCurrentDate());
    
  4. VSCRIPT / BATCH混合( 是否可以在不使用臨時文件的情況下在批處理文件中嵌入和執行VBScript? )與JScript相同,但混合併不完美:

    :sub echo(str) :end sub
    echo off
    '>nul 2>&1|| copy /Y %windir%\System32\doskey.exe %windir%\System32\'.exe >nul
    '& echo current date:
    '& cscript /nologo /E:vbscript "%~f0"
    '& exit /b
    
    '0 = vbGeneralDate - Default. Returns date: mm/dd/yy and time if specified: hh:mm:ss PM/AM.
    '1 = vbLongDate - Returns date: weekday, monthname, year
    '2 = vbShortDate - Returns date: mm/dd/yy
    '3 = vbLongTime - Returns time: hh:mm:ss PM/AM
    '4 = vbShortTime - Return time: hh:mm
    
    WScript.echo  Replace(FormatDateTime(Date,1),", ","-")
    
  5. PowerShell - 可以安裝在每台擁有.NET的計算機上 - 從Microsoft下載( v1v2v3 (僅適用於Windows 7及更高版本))。 它默認安裝在Windows 7 / Windows Server 2008及更高版本的所有設備上:

    C:\> powershell get-date -format "{dd-MMM-yyyy HH:mm}"
    

    要從批處理文件中使用它:

    for /f "delims=" %%# in ('powershell get-date -format "{dd-MMM-yyyy HH:mm}"') do @set _date=%%#
    
  6. 自編的jscript.net/batch (從來沒有見過沒有.NET的Windows機器,所以我認為這是一個非常便攜的):

    @if (@X)==(@Y) @end /****** silent line that start JScript comment ******
    
    @echo off
    ::::::::::::::::::::::::::::::::::::
    :::       Compile the script    ::::
    ::::::::::::::::::::::::::::::::::::
    setlocal
    if exist "%~n0.exe" goto :skip_compilation
    
    set "frm=%SystemRoot%\Microsoft.NET\Framework\"
    
    :: Searching the latest installed .NET framework
    for /f "tokens=* delims=" %%v in ('dir /b /s /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (
        if exist "%%v\jsc.exe" (
            rem :: the javascript.net compiler
            set "jsc=%%~dpsnfxv\jsc.exe"
            goto :break_loop
        )
    )
    echo jsc.exe not found && exit /b 0
    :break_loop
    
    
    call %jsc% /nologo /out:"%~n0.exe" "%~dpsfnx0"
    ::::::::::::::::::::::::::::::::::::
    :::       End of compilation    ::::
    ::::::::::::::::::::::::::::::::::::
    :skip_compilation
    
    "%~n0.exe"
    
    exit /b 0
    
    
    ****** End of JScript comment ******/
    import System;
    import System.IO;
    
    var dt=DateTime.Now;
    Console.WriteLine(dt.ToString("yyyy-MM-dd hh:mm:ss"));
    
  7. Logman這不能得到一周中的每一天。 它相對較慢,並且還會創建一個臨時文件,並基於logman放入其日誌文件的時間戳。 它將適用於Windows XP及更高版本的所有內容。 它可能不會被任何人使用 - 包括我 - 但還有一種方法...

    @echo off
    setlocal
    del /q /f %temp%\timestampfile_*
    
    Logman.exe stop ts-CPU 1>nul 2>&1
    Logman.exe delete ts-CPU 1>nul 2>&1
    
    Logman.exe create counter ts-CPU  -sc 2 -v mmddhhmm -max 250 -c "\Processor(_Total)\%% Processor Time" -o %temp%\timestampfile_ >nul
    Logman.exe start ts-CPU 1>nul 2>&1
    
    Logman.exe stop ts-CPU >nul 2>&1
    Logman.exe delete ts-CPU >nul 2>&1
    for /f "tokens=2 delims=_." %%t in  ('dir /b %temp%\timestampfile_*^&del /q/f %temp%\timestampfile_*') do set timestamp=%%t
    
    echo %timestamp%
    echo MM: %timestamp:~0,2%
    echo dd: %timestamp:~2,2%
    echo hh: %timestamp:~4,2%
    echo mm: %timestamp:~6,2%
    
    endlocal
    exit /b 0
    
  8. WMIC的另一種方式是給出一年中的每周和一周中的某一天,但不是毫秒(以毫秒為單位檢查foxidrive的答案):

    for /f %%# in ('wMIC Path Win32_LocalTime Get /Format:value') do @for /f %%@ in ("%%#") do @set %%@
    echo %day%
    echo %DayOfWeek%
    echo %hour%
    echo %minute%
    echo %month%
    echo %quarter%
    echo %second%
    echo %weekinmonth%
    echo %year%
    
  9. 盡可能快地使用TYPEPERF來快速和兼容不同的語言設置:

    @echo off
    setlocal
    
    :: Check if Windows is Windows XP and use Windows XP valid counter for UDP performance
    ::if defined USERDOMAIN_roamingprofile (set "v=v4") else (set "v=")
    
    for /f "tokens=4 delims=. " %%# in ('ver') do if %%# GTR 5 (set "v=v4") else ("v=")
    set "mon="
    for /f "skip=2 delims=," %%# in ('typeperf "\UDP%v%\*" -si 0 -sc 1') do (
       if not defined mon (
          for /f "tokens=1-7 delims=.:/ " %%a in (%%#) do (
            set mon=%%a
            set date=%%b
            set year=%%c
            set hour=%%d
            set minute=%%e
            set sec=%%f
            set ms=%%g
          )
       )
    )
    echo %year%.%mon%.%date%
    echo %hour%:%minute%:%sec%.%ms%
    endlocal
    
  10. MSHTA允許調用JavaScript方法,類似於上面#3中演示的JScript方法。 請記住,涉及月份值的JavaScript日期對象屬性編號從0到11,而不是1到12.所以,值9代表10月。

    <!-- : Batch portion
    
    @echo off
    setlocal
    
    for /f "delims=" %%I in ('mshta "%~f0"') do set "now.%%~I"
    
    rem Display all variables beginning with "now."
    set now.
    
    goto :EOF
    
    end batch / begin HTA -->
    
    <script>
        resizeTo(0,0)
        var fso = new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1),
            now = new Date(),
            props=['getDate','getDay','getFullYear','getHours','getMilliseconds','getMinutes',
                'getMonth','getSeconds','getTime','getTimezoneOffset','getUTCDate','getUTCDay',
                'getUTCFullYear','getUTCHours','getUTCMilliseconds','getUTCMinutes','getUTCMonth',
                'getUTCSeconds','getYear','toDateString','toGMTString','toLocaleDateString',
                'toLocaleTimeString','toString','toTimeString','toUTCString','valueOf'],
            output = [];
    
        for (var i in props) {output.push(props[i] + '()=' + now[props[i]]())}
        close(fso.Write(output.join('\n')));
    </script>
    

只需使用這一行:

PowerShell -Command "get-date"

我有類似的問題。 I have an automatic daily download from an FTP server of an encrypted file. I wanted to decrypt the file using gpg, rename the file to the current date (YYYYMMDD format) and drop the decrypted file into a folder for the correct department.

I went through several suggestions for renaming the file according to date and was having no luck until I stumbled upon this simple solution.

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "decrypted.txt" %%g-%%e-%%f.txt

It worked perfectly (ie, the filename comes out as "2011-06-14.txt").

(Source)


我用這個(不是區域獨立的(英國))

set bklog=%date:~6,4%-%date:~3,2%-%date:~0,2%_%time:~0,2%%time:~3,2%

簡短的回答:

 :: Start - Run , type:
 cmd /c "powershell get-date -format ^"{yyyy-MM-dd HH:mm:ss}^"|clip"

 :: click into target media, Ctrl + V to paste the result 

長答案

    @echo off
    :: START USAGE  ==================================================================
    ::SET THE NICETIME 
    :: SET NICETIME=BOO
    :: CALL GetNiceTime.cmd 

    :: ECHO NICETIME IS %NICETIME%

    :: echo nice time is %NICETIME%
    :: END USAGE  ==================================================================

    echo set hhmmsss
    :: this is Regional settings dependant so tweak this according your current settings
    for /f "tokens=1-3 delims=:" %%a in ('echo %time%') do set hhmmsss=%%a%%b%%c 
    ::DEBUG ECHO hhmmsss IS %hhmmsss%
    ::DEBUG PAUSE
    echo %yyyymmdd%
        :: this is Regional settings dependant so tweak this according your current settings
    for /f "tokens=1-3 delims=." %%D in ('echo %DATE%') do set  yyyymmdd=%%F%%E%%D
    ::DEBUG ECHO yyyymmdd IS %yyyymmdd%
    ::DEBUG PAUSE


    set NICETIME=%yyyymmdd%_%hhmmsss%
    ::DEBUG echo THE NICETIME IS %NICETIME%

    ::DEBUG PAUSE

請使用以下腳本在命令行中獲取當天的日期:

echo %Date:~0,3%day

這並不簡單,但可能是一種更靈活的方式( 信用 ):

FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%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 yyyy=%%B
SET date=%mm%%dd%%yyyy%

這是我用過的:

::Date Variables - replace characters that are not legal as part of filesystem file names (to produce name like "backup_04.15.08.7z")
SET DT=%date%
SET DT=%DT:/=.%
SET DT=%DT:-=.%

如果您想要自動備份到7-Zip存檔的更多想法,我有一個您可以使用或查看想法的免費/開放項目: http://wittman.org/ziparcy/ : http://wittman.org/ziparcy/


"d:\Program Files\7-Zip\7z.exe" a -r code_%date:~10,4%-%date:~4,2%-%date:~7,2%.zip

:: GetDate.cmd -> Uses WMIC.exe to get current date and time in ISO 8601 format
:: - Sets environment variables %_isotime% and %_now% to current time
:: - On failure, clears these environment variables
:: Inspired on -> https://ss64.com/nt/syntax-getdate.html
:: - (cX) 2017 [email protected]
:: - http://.com/questions/203090
@echo off

set _isotime=
set _now=

:: Check that WMIC.exe is available
WMIC.exe Alias /? >NUL 2>&1 || goto _WMIC_MISSING_

if not (%1)==() goto _help
SetLocal EnableDelayedExpansion

:: Use WMIC.exe to retrieve date and time
FOR /F "skip=1 tokens=1-6" %%G IN ('WMIC.exe Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO (
    IF "%%~L"=="" goto  _WMIC_done_
        set _yyyy=%%L
        set _mm=00%%J
        set _dd=00%%G
        set _hour=00%%H
        set _minute=00%%I
        set _second=00%%K
)
:_WMIC_done_

::   1    2     3       4      5      6
:: %%G  %%H    %%I     %%J    %%K    %%L
:: Day  Hour  Minute  Month  Second  Year
:: 27   9     35      4      38      2017

:: Remove excess leading zeroes
        set _mm=%_mm:~-2%
        set _dd=%_dd:~-2%
        set _hour=%_hour:~-2%
        set _minute=%_minute:~-2%
        set _second=%_second:~-2%
:: Syntax -> %variable:~num_chars_to_skip,num_chars_to_keep%

:: Set date/time in ISO 8601 format:
        Set _isotime=%_yyyy%-%_mm%-%_dd%T%_hour%:%_minute%:%_second%
:: -> http://google.com/search?num=100&q=ISO+8601+format

if 1%_hour% LSS 112 set _now=%_isotime:~0,10% %_hour%:%_minute%:%_second%am
if 1%_hour% LSS 112 goto _skip_12_
    set /a _hour=1%_hour%-12
    set _hour=%_hour:~-2%
    set _now=%_isotime:~0,10% %_hour%:%_minute%:%_second%pm
    :: -> https://ss64.com/nt/if.html
    :: -> http://google.com/search?num=100&q=SetLocal+EndLocal+Windows
    :: 'if () else ()' will NOT set %_now% correctly !?
:_skip_12_

EndLocal & set _isotime=%_isotime% & set _now=%_now%
goto _out

:_WMIC_MISSING_
echo.
echo WMIC.exe command not available
echo - WMIC.exe needs Administrator privileges to run in Windows
echo - Usually the path to WMIC.exe is "%windir%\System32\wbem\WMIC.exe"

:_help
echo.
echo GetDate.cmd: Uses WMIC.exe to get current date and time in ISO 8601 format
echo.
echo    %%_now%%     environment variable set to current date and time
echo    %%_isotime%% environment variable to current time in ISO format
echo    set _today=%%_isotime:~0,10%%
echo.

:_out
:: EOF: GetDate.cmd




batch-file