Last post Aug 31, 2007 04:45 PM by LockH
Aug 28, 2007 05:28 PM|TToad|LINK
I am using Visual Studio 2005 on XP Pro with IIS 5.1 installed.
On any of the sites I develop I use the culture="en-GB" attribute in the globalization tag of the web.config file.
If I run the page on thr development server that comes with Visual Studio the date appear in the UK format (DD/MM/YY). However if I use IIS 5.1 the date appears in the US format.
Please can anyone advise how I can get Internet Information Server to supply the correct date format.
Aug 29, 2007 08:34 AM|vivek_iit|LINK
What is the culture setting on your local machine (go to Control Panels-?Languages->regional settings)?
Aug 29, 2007 09:10 AM|TToad|LINK
This is set to English(United Kingdom)
Aug 29, 2007 11:16 AM|vivek_iit|LINK
Try to use the culture setting in the <% Page %> tag itself.
I found a similar thread: http://forums.iis.net/p/1110292/1708382.aspx#1708382
seems an interesting issue, I think I need to check it out myself (doing the same thing), meanwhile you see if setting the culture in the Page works.
Aug 29, 2007 01:01 PM|LockH|LINK
I struggled with this problem for a couple of months.
Setting culture and uiculture in the page and web config and code did not help.
Eventually in desperation I copied my site and database to another "identical" machine, and it worked OK there.
There seems to be a bug in IE5.1 on XP Pro that is inconsistent about where it takes the short date format from, so that it even switches format in one field in mid transaction, eg when a gridview or formview changed mode from inspect to edit; it would display
a date as 31/12/2006 then reject that same date in edit mode unless it was changed to 12/31/2006.
It doesn't happen on every XP Pro/ IE5.1 installation, I had the problem on one machine out of two that had the same XP PRo SP2 and .NET 2 and MS SQL. I did clean installs on two other machines and the problem didn't affect them either. I suspect it depends
on what else has been installed, and in what order, maybe even long before VS or .NET, to trigger it. The machine that had the problem was 4 years old, and had a lot of different stuff installed at different times. But I couldn't afford a week of experimental
installs to establish exactly what combination did it.
Anyway, to get around it, search your registry for SHORTDATE and you will find one or more (maybe associated with a VS or VWD Express install?) that is set to format "M/d/yyyy" or "MM/dd/yyyy". Change it to "dd/MM/yyyy".
Maybe search for "M/d/y" and "MM/dd/y" too, just in case.
That fixed it for me, and I hope it works for you too, but there is no warranty.
Aug 29, 2007 02:31 PM|TToad|LINK
I tried the culture attribute at page level and the problem persisted.
I have also searched the registry as advised and the SHORTDATE was in the correct format (dd/MM/yyyy).
Aug 29, 2007 05:01 PM|LockH|LINK
You would expect to find at least one correct format, eg in the international section.
But did you search again all the way to the end of the registry?
I found a couple of correct ones, and a wrong one.
Aug 30, 2007 10:12 AM|TToad|LINK
I re checked I had searched the registry and the SHORTDATE only appeared as dd/MM/yyyy
Aug 30, 2007 11:14 AM|LockH|LINK
Post a sample of markup so we can have a look?
Aug 30, 2007 03:44 PM|TToad|LINK
" <globalization culture="en-GB" uiCulture="en-GB" />"
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default1.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Button" /></div>
Partial Class _Default
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = Date.Now.Date & " " & FormatCurrency(2423.234)
Aug 30, 2007 04:38 PM|TToad|LINK
Sorry but I have just searched the registry again and I have found an entry in the international section M/d/yyy. Modifying a suggested has produced the desired result.
Thanks for everyone's help. This has been driving me up the wall.
Aug 30, 2007 08:06 PM|LockH|LINK
Glad to be of help.
Did you happen to notice where that M/d/y was? Users rather than local machine?
I wonder if the ASP or IIS user gets installed with american dates by default?
By the way, it is considered good practice to click the Answer and mark the problem as solved. :-)
Aug 31, 2007 10:24 AM|TToad|LINK
It was in HKEY_USERS.
I had the same problem on my laptop and could not find the problem registry entry with regedit.
I had to use regseeker to find the entry.
Aug 31, 2007 04:45 PM|LockH|LINK
I should have taken careful note of what I changed on my dev pc, but like I said, I suspect the aspnet user gets created with en-US dates, and IIS 5.1 seems to be inconsistent about where it takes the dateformat from at different times, different modes.