|
This is very commonly known setup yet very important so I think it is worth sharing. One of our developer partners struggled with this problem for 2 days! Finally he did the right thing - contacted someone extremely intelligent like myself. :)
Does the C# Convert.ToDateTIme function read date as "dd/mm/yyyy" or "mm/dd/yyyy"?
When the application on the local machine is uploaded to remote shared server, it started giving date/time error. It was working perfectly on local machine reading "dd/mm/yyyy", but on remote machine, it seems to read dates as "mm/dd/yyyy". The culture setting was checked and there is same culture setting "en-GB" on both.
Here is the culture-proof way of reading date strings from a SQL Server 2000 database?
Answer:
The format of the DataTime will depend on the current culture of your application. In order to have a specific format throught your application you can set the <globalization> tag in the web.config file under <system.web> section. In such case you need not write code to convert the datatime to proper format. By default all the dates will be set to the format specified.
<system.web> <globalization culture="en-GB" uiCulture="en-GB" requestEncoding="utf-8" responseEncoding="utf-8" /> </system.web>
|