TAD "Current date: $M $d,$Y ($D)$lCurrent time: $H:$n:$s 作者: Roy 时间: 2003-5-14 00:00 轉載過來的:
----------------------
:: Parse the current date and time into multiple variables
:: Adds a zero to %hrs% if only one digit is present
@echo off
if "%1"=="GoTo:" %1%2 (Subroutine Handler)
echo @PROMPT SET TIME=$T$_SET DATE=$D$_> %TEMP%.\T1.BAT
%COMSPEC% /e:1024 /c %TEMP%.\T1.BAT > %TEMP%.\T2.BAT
type nul> %TEMP%.\T1.BAT
for %%? in (0D 10 13 27 2A) do echo e1%%?';'>> %TEMP%.\T1.BAT
for %%? in (w q) do echo %%?>> %TEMP%.\T1.BAT
DEBUG %TEMP%.\T2.BAT nul
call %TEMP%.\T2.BAT
:: Depending on the COUNTRY command from config.sys, swapping
:: the words 'month' and 'date' in next line could be necessary
call %0 GoTo: setvars %time% %date% hrs min sec dsec day month date year
FIND "= " nul
if not errorlevel=1 set hrs=0%hrs%
for %%? in (1 2) do del %TEMP%.\T%%?.BAT
echo Hrs: %hrs%
echo Min: %min%
echo Sec: %sec%
echo DSec: %dsec%
echo Day: %day%
echo Month: %month%
echo Date: %date%
echo Year: %year%
goto EOF
:setvars
if "%1"=="GoTo:" SHIFT
SHIFT
if "%9"=="" goto eof
set %9=%1
goto setvars