0

Hi i am using bootstrap datepicker. I need to get the value from datepicker text box in the format like date-month-year to my controller but presently i am getting values like Tue Oct 01 00:00:00 IST 2013

I have tried formatting date but still i am getting same result . I have tried like below

$(function() {
    window.prettyPrint && prettyPrint();
    $('#birthday').datepicker({
        format: "DD, d MM, yy"
    })
});
4

1 回答 1

1

If the format attribute is not working. You can try something similar to this:

var dt = $('#dt').datepicker({format:'dd/mm/yyyy'}).on('changeDate', function(ev) {

   var newDate = new Date(ev.date);
   var year = newDate.getFullYear();
   var month = (newDate.getMonth()+1);
   var day = newDate.getDate();

   dt.setValue(day+'-'+month+'-'+year);
   dt.hide();

}).data('datepicker');

You are formatting your date by yourself. You can ignore the format attribute.

于 2014-01-09T17:19:53.667 回答