views:

35

answers:

3

Hi,

On one of my pages I display a datetime (from a database) and it is formatted correctly as a UK date time (dd-mm-yyyy) on my local machine. However when I deploy it to a server it reverts to American format (mm-dd-yyyy). Does anyone have any idea of when this might be happening?

This might be outside the scope of stackoverflow but I've check the server settings and everything seems to be set as UK in the regional settings.

Thanks

+1  A: 

You could set the UI culture in your web.config:

<globalization 
    requestEncoding="utf-8" 
    responseEncoding="utf-8" 
    culture="en-GB" 
    uiCulture="en-GB" />

or use the [DisplayFormat] attribute on a particular property of your view model:

[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd-mm-yyyy}")]
public DateTime Date { get; set; }
Darin Dimitrov
A: 

You can set the culture in the web.config via the globalization tag.

E.g: <globalization culture="auto:en-GB" uiCulture="auto:en-GB">

Henryk
+2  A: 

This will be because the hosting/server is set to use american datetime when it was installed. unfortunately changing the settings now wont help .net.

you need to define the culture you wish to use in the webconfig:

<configuration>
   <system.web>
      <globalization culture="en-GB"/>
   </system.web>
</configuration>
JamesStuddart