Date binding issue showing incorrect month.

2 posts, 0 answers
  1. Jacques
    Jacques avatar
    138 posts
    Member since:
    Jun 2007

    Posted 29 Nov 2013 Link to this post

    See the following HTML: 

    <input id="dateFor" data-role="datepicker" data-format="MMM yyyy" data-bind="value: dateFilter, events: { change: dateForChange }" class="bindable" />
    here's the viewModel: 

    var viewModel = kendo.observable({ dateFilter: new Date(2013,11,1)});
     
    //bind
    kendo.bind($('.bindable'), viewModel);

    The resulting date picker shows the date as Dec 2013 in Firefox. IE and Chrome (didn't test Safari). 

    If you set the month to 12, it ignores the year value and jumps to Jan 2014. 

    Regards,
    Jacques
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 29 Nov 2013 Link to this post

    Hello Jacques,

    In JavaScript the Date object has zero based months. Thus 11 represents December. More info is available here

    month
    Integer value representing the month, beginning with 0 for January to 11 for December.


    Regards,
    Atanas Korchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top