Reputation: 197
I'm working with a group on a project that at one point requires a DateTime to be posted in a form. We added a simple jquery-ui datepicker to do that, and it worked fine on my English configured machine. However when they tried using it themselves on a Dutch configured machine, the DateTime started using a different format, while the datepicker kept the same English format, causing errors.
How do I lock the DateTime localization in MVC4 (or the overall localization) to English to fix this? Alternatively, how do I detect the localization to make the datepicker use the different one?
Upvotes: 0
Views: 1935
Reputation: 17288
Try this:
<globalization culture="en-US" uiCulture="en-US" />
This will also fix potential problems with float
's and etc (point vs comma)
Upvotes: 3
Reputation: 111
You could use a DataAnnotation to your DateTime object
[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy HH:mm}")]
public DateTime dateTime;
then edit your format string to the English standard. If i am correct, it will always use this format.
Upvotes: 0