不简单,但确实有人写出来了。以下转帖,CN-DOS HAT编辑:
-
- @echo off
- rem 需要reg.exe的支持
- rem 无法保证在中、英之外的其它语言的操作系统上得到正确结果
- for /f "skip=4 delims= " %%a in ('reg query "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate') do set DateFormat=%%a
- set DateFormat=%DateFormat:~-8%
- reg add "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate /t REG_SZ /d yyyy-M-d /f>nul
- set Today=%date: =%
- reg add "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate /t REG_SZ /d %DateFormat% /f>nul
- set "Week=Mon Tue Wed Thu Fri Sat Sun 星期一 星期二 星期三 星期四 星期五 星期六 星期日"
- for %%a in (%Week%) do call set "Today=%%Today:%%a=%%"
- echo %Today%
复制代码
-
- @echo off
- rem 需要reg.exe的支持
- for /f "skip=4 delims= " %%a in ('reg query "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate') do set DateFormat=%%a
- set DateFormat=%DateFormat:~-8%
- reg add "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate /t REG_SZ /d yyyy-M-d /f>nul
- set Today=%date: =%
- reg add "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate /t REG_SZ /d %DateFormat% /f>nul
- if "%Today:~0,1%" gtr "9" (
- set Today=%Today:~-10%
- ) else (
- set Today=%Today:~0,10%
- )
- echo %Today%
复制代码
-
- @echo off
- rem 需要reg.exe的支持
- for /f "skip=4 delims= " %%a in ('reg query "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate') do set DateFormat=%%a
- set DateFormat=%DateFormat:~-8%
- reg add "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate /t REG_SZ /d yyyy-M-d /f>nul
- type nul>"%temp%\MyFile.tmp"
- for /f %%a in ('dir "%temp%\MyFile.tmp" ^| findstr /i "MyFile.tmp"') do set Today=%%a
- reg add "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate /t REG_SZ /d %DateFormat% /f>nul
- echo %Today%
复制代码
-
- @echo off
- rem 需要WMIC的支持
- for /f "tokens=2 delims==" %%a in ('wmic path win32_operatingsystem get LocalDateTime /value') do set t=%%a
- set Today=%t:~0,4%-%t:~4,2%-%t:~6,2%
- echo %Today%
复制代码
-
- @echo off
- rem 需要调用VBS
- >"%temp%\MyDate.vbs" echo dt=date()
- >>"%temp%\MyDate.vbs" echo s=right(year(dt),4) ^& "-" ^& right("0" ^& month(dt),2) ^& "-" ^& right("0" ^& day(dt),2)
- >>"%temp%\MyDate.vbs" echo wscript.echo s
- for /f %%a in ('cscript /nologo "%temp%\MyDate.vbs"') do set Today=%%a
- echo %Today%
复制代码
|