jQuery UI DatePicker - Change Date Format

前端 未结 28 1840
后悔当初
后悔当初 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 17:21

    inside the jQuery script code just paste the code.

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

    this should work.

    0 讨论(0)
  • 2020-11-21 17:23

    This is what worked for me:

    $.fn.datepicker.defaults.format = 'yy-mm-dd'
    
    0 讨论(0)
  • 2020-11-21 17:24

    $("#datepicker").datepicker("getDate") returns a date object, not a string.

    var dateObject = $("#datepicker").datepicker("getDate"); // get the date object
    var dateString = dateObject.getFullYear() + '-' + (dateObject.getMonth() + 1) + '-' + dateObject.getDate();// Y-n-j in php date() format
    
    0 讨论(0)
  • 2020-11-21 17:24

    If you need the date in yy-mm-dd format,you can use this:-

    $("#datepicker").datepicker({ dateFormat: "yy-mm-dd" });
    

    You can find all the supported format https://jqueryui.com/datepicker/#date-formats

    I was in need of 06,Dec 2015,I did this:-

    $("#datepicker").datepicker({ dateFormat: "d M,y" });
    
    0 讨论(0)
提交回复
热议问题