Difference in command line date format between XP & Windows 7

2

1

The DATE command in XP gives the date in the format ddd dd/mm/yyyy e.g. Sun 12/12/2010. In Windows 7, it only gives dd/mm/yy I.e. 12/12/2010.
Both have the same regional settings.
Can Windows 7 be forced to display the date in the same way as XP, or can the day be extracted in the ddd format?

PC112

Posted 2010-12-11T23:19:05.820

Reputation: 21

I've just tried date on my XP and it output it as 11/12/2010 (UK) format and then prompted me for the new date. date /t just outputs the current date (again without the day). – ChrisF – 2010-12-11T23:24:42.420

WIn 7 gives me XP-style http://i.imgur.com/EJwbS.png

– Sathyajith Bhat – 2010-12-11T23:26:15.760

1You probably have different locale settings on the two OSes. IIRC they're called “Regional settings” in the Control Panel in Windows XP. – Gilles 'SO- stop being evil' – 2010-12-12T00:39:17.150

You are correct - that happens with UK regional settings. I am using Australian settings in both XP & Win7 & they produce different results. – PC112 – 2010-12-12T02:03:02.963

I have just found a solution by changing the "Short Date" format to a customised one: "ddd dd/mm/yyyy". This gives the same result at the command line as XP with standard Australian settings. I just have to test what other impacts it will have. – PC112 – 2010-12-12T02:18:54.097

Answers

4

This is controlled by the "Short Date" setting under Control Panel → Region and Language → Format tab → Additional Settings → Date tab

Observe the results of date /t with short date set to "M/d/yyyy", then to "MM/dd/yyyy":

alt text

alt text

Stephen Jennings

Posted 2010-12-11T23:19:05.820

Reputation: 21 788

As I said in my previous post - changing the regional settings did provide the correct result for the Command Line format, but it also changed the format in many other systems which made it unacceptable. So it is back to square one. I either have to find a solution that enables me to provide the same format for Date in Win7 as it did in XP (Australian settings), otherwise I have to rewrite a whole lot of batch files. Anyone have any suggestions???? – PC112 – 2010-12-13T12:41:59.897

Thanks for this one. I'm using English(Australia) on Windows Server 2003 and had the same problem with two users with apparently the same regional settings. Even the example short date format had both as 7/11/2011. Only be going into the customize option did I find d/MM/yyyy and dd/MM/yyyy. – Richard A – 2011-11-07T03:38:55.827

1

Found from this Stack Overflow answer, UnxUtils contains a date.exe which can take a specified format parameter.

date.exe +"%a %m/%d/%Y"
Mon 12/13/2010

UnxUtils contains a lot of other files, but I just confirmed you can just take date.exe and run it independently of everything else.

Note that you need to call it as date.exe or path\to\date and not just date, because otherwise the built-in shell command will run instead. Or, you can rename it to something like DateFormat.exe.

Stephen Jennings

Posted 2010-12-11T23:19:05.820

Reputation: 21 788

0

I have tested the date.exe app from UnxUtils & it has worked successfully so far in my test environment. I am about to implement it in one of my smaller client's environment & if that is successful, I will roll it out on all my clients sites. Thanks for the pointer to UnxUtils.

pc112

Posted 2010-12-11T23:19:05.820

Reputation: 1