I am using the following code to send a get request to my controller when I detect a client side change to the Telerik MVC DatePicker.
function RaceDate_onChange() {
var pickedDate = $(this).data('tDatePicker').value();
$.get("/RaceCard/Details?year=" + pickedDate.getYear() + "&month=" + pickedDate.getMonth() + "&day=" + pickedDate.getDay());
}
[HttpGet]
public ActionResult Details(int year, int month, int day)
I am building the URL with d/m/y values of 2011/7/10, yet the d/m/y values arriving at my controller action are 111/6/0. If I inspect the HttpContext.Request object at a breakpoint in my controller, I observe these suspicious values:
Url: {http://localhost:59927/RaceCard/Details?year=111&month=6&day=0}
UrlReferrer: {http://localhost:59927/RaceCard/Details?year=2011&month=7&day=10}
I think this is purely a JS issue, but I have no clue where to start, except here on SO.
getYear() returns the number of years since 1900. Use getFullYear() instead.
getMonth() is zero based so January = 0, February = 1
getDay() returns a zero based integer representation of the day of the week e.g. Sunday = 0, Monday = 1. You want to use getDate() which returns the date of the month