简体   繁体   中英

Change date format on datepicker

Hi i using this code to show a expiration date based on the select.

<script>    
$(function(){                  
    $("#date_picker").datepicker();
    $("#Plano_Id").change(function() {
        var offset = +$(this).find("option:selected").attr("title"), /* get days to add on date*/
        theDate = new Date();
        theDate.setDate(theDate.getDate() + offset);         
        $("#date_picker").datepicker("setDate", theDate);
    });    
});        
</script>

But this returns the date in this format mm/dd/yyyy . I'm trying to show dd/mm/yyyy

For setting the format for a specific date control

$('#datepicker').datepicker({ dateFormat: 'dd/mm/yyyy' });

For setting it throughout your site/page, use

$.datepicker.setDefaults({ dateFormat: 'dd/mm/yyyy' });
//Note:Call this before initializing any date pickers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM