Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I use the datepicker from jQuery UI, but the format is like example today: 08/01/2013

But i want the format to be example today: 2013-08-01

Here is code line i think maybe i should use?

`$( "#txtFromDate" ).datepicker( "option", "dateFormat", "yyyy-mm-dd" );`

And here is my jQuery code i use that works fine but don't know where to put the line? And i want the format in both of my fields.

`
$(document).ready(function(){
    $("#txtFromDate").datepicker({
        minDate: "07/17/2012",
        maxDate: "0D",
        numberOfMonths: 2,
        onSelect: function(selected) {
          $("#txtToDate").datepicker("option","minDate", selected);
        }
    });
    $("#txtToDate").datepicker({ 
        minDate: "07/17/2013",
        maxDate:"0D",
        numberOfMonths: 2,
        onSelect: function(selected) {
           $("#txtFromDate").datepicker("option","maxDate", selected);
        }
    });  
});`

I hope somebody have a solution for this :-)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
161 views
Welcome To Ask or Share your Answers For Others

1 Answer

since your already have other options in the datepicker... add it there.

try this

$("#txtFromDate").datepicker({
    minDate: "07/17/2012",
    maxDate: "0D",
    numberOfMonths: 2,
    dateFormat: "yy-mm-dd", //<----here
    onSelect: function(selected) {
      $("#txtToDate").datepicker("option","minDate", selected);
    }
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...