jQuery UI DatePicker - Change Date Format

前端 未结 28 1835
后悔当初
后悔当初 2020-11-21 16:39

I am using the UI DatePicker from jQuery UI as the stand alone picker. I have this code:

And the

相关标签:
28条回答
  • 2020-11-21 16:57

    This works too:

    $("#datepicker").datepicker({
        dateFormat:'d-m-yy'
    });
    
    0 讨论(0)
  • 2020-11-21 16:58

    Try to use the

    $( ".selector" ).datepicker({ dateFormat: 'dd/mm/yy' });  
    

    and there is lots of option available For the datepicker you can find it Here

    http://api.jqueryui.com/datepicker/
    

    This is the way we call the datepicker with the parameter

    $(function() {
          $('.selector').datepicker({
                dateFormat: 'dd/mm/yy',
                changeMonth: true,
                numberOfMonths: 1,
                buttonImage: 'contact/calendar/calendar.gif',
                buttonImageOnly: true,
                onSelect: function(selectedDate) {
                     // we can write code here 
                 }
          });
    });
    
    0 讨论(0)
  • 2020-11-21 17:00

    Here's one specific for your code:

    var date = $('#datepicker').datepicker({ dateFormat: 'dd-mm-yy' }).val();
    

    More general info available here:

    • http://api.jqueryui.com/datepicker/#option-dateFormat
    • http://api.jqueryui.com/datepicker/#utility-formatDate
    0 讨论(0)
  • 2020-11-21 17:01

    you can simply use this format in you function just like

         $(function() {  
            $( "#datepicker" ).datepicker({
                dateFormat: 'dd/mm/yy',
              changeMonth: true,
              changeYear: true
            });
          });
    
    <input type="text" id="datepicker"></p>
    
    0 讨论(0)
  • 2020-11-21 17:01
    <script>
        $(function() {  
            $("#datepicker").datepicker(); 
            $('#datepicker').datepicker('option', {dateFormat: 'd MM y'});
        }); 
        $("#startDate").datepicker({dateFormat: 'd MM y'}); 
    </script>
    
    0 讨论(0)
  • 2020-11-21 17:02

    I am using jquery for datepicker.These jqueries are used for that

    <script src="jqueryCalendar/jquery-1.6.2.min.js"></script>
    <script src="jqueryCalendar/jquery-ui-1.8.15.custom.min.js"></script>
    <link rel="stylesheet" href="jqueryCalendar/jqueryCalendar.css">
    

    Then you follow this code,

    <script>
         jQuery(function() {
         jQuery( "#date" ).datepicker({ dateFormat: 'dd/mm/yy' });
                    });
    </script>
    
    0 讨论(0)
提交回复
热议问题