如何在命令提示符中更改%date%的格式?

时间:2014-02-12 18:22:12

标签: date cmd command-prompt dayofweek

如何在命令提示符中更改echo %date%的输出格式?在一个系统中,我收到输出为Wed 02/12/2014,但在另一个系统中,我收到输出为02/12/2014。我在两个系统上输入的命令是echo %date%

我基本上需要知道的是星期几。因此,如果无法更改格式,那么命令行中是否还有其他命令可以获取星期几?

1 个答案:

答案 0 :(得分:1)

此解决方案最近发布,在XP Home之后的任何PC上都应该可以正常工作。

@echo off  
set "daysofweek=Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday"  
for /F "skip=2 tokens=2 delims=," %%a in ('wmic Path Win32_LocalTime Get DayOfWeek /Format:csv') do set "daynumber=%%a"
for /F "tokens=%daynumber% delims=," %%b in ("%daysofweek%") do set "dow=%%b"
echo "%dow%", "%daynumber%"
pause