1
votes

I am using Bootstrap Date picker in MVC c# application. I've bind date picker with current date. Format of date picker is dd/mm/yyyy.

Jquery
$(".datepicker").datepicker({ format: "dd/mm/yyyy", autoclose: true });

Razor

@Html.TextBox("AppointmentDate", @Model.NewAppointmet.Appointment_Date.Value.ToString("dd/MM/yyyy"), new { @class = "form-control datepicker", placeholder = "Appointment Date", id = "AppointmentDate" })

When Page load, datepicker shows correct date enter image description here

But When I open datepicker it shows wrong date enter image description here

2
Hey buddy , did you got any thing regarding this issue ? I am also getting the same issue. Please provide the solution if you have. ;) - Krunalsinh
My answer seems to be late but as the saying goes better late than never. I had a similar issue with my date picker, to fix the issue i switched to a different date picker new datepicker. This fixed my issue. it seems the previous datepicker was not using the specified format to parse the date on the users laptop. hope this helps. :) - KwakuCsc

2 Answers

0
votes

MM: Abbreviated and full month names(eg. January)

try using this code

@Html.TextBox("AppointmentDate", @Model.NewAppointmet.Appointment_Date.Value.ToString('dd/mm/yyyy'), new { @class = "form-control datepicker", placeholder = "Appointment Date", id = "AppointmentDate" })
-2
votes

Try this in jquery. Try using capital M instead of m

$(".datepicker").datepicker({ format: "dd/MM/yyyy", autoclose: true });