My website is hosted on multiple servers at different locations
Everywhere the Culture of the data format is different- we use mm/dd/yyyy format every where but incase some server has the culture set to dd/mm/yyyy then our website generates Datetime exception.
You should be specifying what culture you want to use whenever you convert a string to a date.
The culture you should be using depends on what culture the dates are formatted as. For example, if all dates you are parsing are formatted as Slovak:
Then you need to parse the string as though it were in Slovak (Slovakia) (
sk-SK) culture:If your dates are all in Tajik (Tajikistan Cyrillic), then you need to parse it as
tg-Cryl-Tj:Which leads to the question: what date format are you using? You should not be relying on the locale setting of the server, you should be deciding what format you want.
i suspect that you prefer to do everything in English. But then you have to decide which variant of English:
en-AU(English Austrailia):24/10/2011en-IA(English India):24-10-2011en-ZA(English South Africa):2011/10/24en-US(English United States):10/24/2011i suspect you prefer English (India) (
en-IA).But if you really can’t decide what culture to use when converting dates to strings and vice-versa, and the dates are never meant to be shown to a user, then you can use the Invariant Culture: