1

Model date for english culture :- 3/28/2018 and same model date for arabic culture:- 11/07/39. I have a page with datepicker, it is binded with model date. For the same page with english culture, the date is shown as ex: 3/28/2018 and for the same page when i change the culture to arabic then the date is selected as 11/07/39.

I don't understand why it is happening and how to fix it. Please help me in this. Thanks

Sunny N
  • 11
  • 5
  • by default the culture is set to `en-us` if you wish to set the format for your expected culture maybe this will help https://stackoverflow.com/questions/30214813/wrong-currency-unit-in-kendo/30220795#30220795 – David Shorthose Apr 17 '18 at 12:42
  • Sorry for the late reply. Thanks, as per the above link it is displaying correctly for arabic culture also. But here the problem is when i pass selected date from en datepicker to a controller through ajax jquery call then it is working as expected. But for the same datepicker with ar culture, the selected date is not passing to the same controller. Here it is written in console that date(datetime param of controller) can't be null. – Sunny N May 07 '18 at 18:44
  • two questions. 1) Is there a reason for the back end system to be configured differently to the front end culture wise? 2) If the answer to question 1 is Yes then why not convert the date to a string in the format of dd MMM yyyy before sending it back to the controller. – David Shorthose May 08 '18 at 09:55
  • Thanks David. Now am able to pass that date to controller after converting it into string format. – Sunny N May 08 '18 at 17:44

1 Answers1

0

If you only want to change the format of this datepicker and the culture is set server-side you can use this:

@Html.Kendo().DatePickerFor(m => m.Date).Format(System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern)
Martin D.
  • 1,950
  • 3
  • 23
  • 33