How to change the format of the day in javascript?

1

Good person, the scene is that I have here the script that makes when making a reservation, you can not select the day of yesterday, and such, .. but when I go to see the date appears in the format MM-DD-YYYY , and I do not know how to make it DD-MM-YYYY

//Script para que só se possa selecionar a data de hoje
$(document).ready(function(){
    $("#StartDate").datepicker({
        minDate: 0,
        maxDate: "+60D",
        numberOfMonths: 1,
        onSelect: function(selected) {
          $("#txtToDate").datepicker.formatDate("dd-mm-yy","option","minDate", selected)

        }
    });
    //Script para que só se possa selecionar o dia de amanhã e os restantes
    $('#EndDate').datepicker({
        minDate: 0,
        maxDate:"+60D",
        numberOfMonths: 2,
        onSelect: function(selected) {
           $("#StartDate").datepicker("option","maxDate", selected)
        }
    }); 
});
    
asked by anonymous 01.06.2015 / 21:06

2 answers

1

The datepicker API has an option for this . You have to pass in the dateFormat: 'dd-mm-yy' configuration object. In your case the code could be:

$("#StartDate").datepicker({
    minDate: 0,
    maxDate: "+60D",
    numberOfMonths: 1,
    dateFormat: 'dd-mm-yy' // <-----------
    // etc...

Example: link

    
01.06.2015 / 21:12
1

My friend, since we are talking about the default pt-br , in addition to the answer given by your friend Sergio, I believe that the issues I made in the link below can help you a lot.
link

    
01.06.2015 / 21:37