标题: 我想直接得到dos下的日期和时间而不用输入怎么办?
[打印本页]
作者: eidolon
时间: 2003-5-12 00:00
标题: 我想直接得到dos下的日期和时间而不用输入怎么办?
我使用date > 1.txt
可是总是需要回车一下,谁有更好的解决办法?
作者: Wengier
时间: 2003-5-13 00:00
试试:
echo.|date>1.txt
作者: pfox
时间: 2003-5-13 00:00
Quote: |
以下是引用Wengier在2003-5-13 0:02:56的发言:
试试:
echo.|date>1.txt |
|
这样不行的。我记得在NT、2K、XP下面可以用DATE /T来输出日期,在9X就不知道怎么处理。
作者: Wengier
时间: 2003-5-13 00:00
这样做可以呀!我刚才还试过呢!
作者: pfox
时间: 2003-5-14 00:00
这样取出的不止有日期,还有其他的字符。
作者: Wengier
时间: 2003-5-14 00:00
如果只想得到日期、时间而不能有其它字符的话,则用TAD.EXE等程序就可以了。例如:
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
:eof
作者: eidolon
时间: 2003-5-19 00:00
谢谢大家,我已经搞定了,用TC2写了个小程序,很简单的。