I am having a problem with an MVC3 application using a jQuery UI DatePicker object.
Within the MVC application, I ask the user to pick their required culture, i.e en-GB, which then formats all dates and currencies in the application in the british format.
I can then access the formatter code for this via Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern
However, the format returned for UK dates is: dd/MM/yyyy
To format the resulting data from the jQuery UI datepicker, I need to specify a date format. But for UK format dates, I need to specify the format as dd/mm/yy
The simple solution would be to just use Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern
in my jQuery calls to format the date, but obviously this gives a formatting inconsistency as this is interpreted differently by jQuery UI (01/December/20112011
instead of 01/12/2011
)
Is there any easy way around this?
The only way I can think of doing it is asking the user twice what format to display dates in?