格式日期在jQuery UI datepicker [英] format date in jQuery UI datepicker

查看:106
本文介绍了格式日期在jQuery UI datepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery UI中的datepicker,但格式就像今天的例子: 08/01/2013

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

但是我想要格式是今天的例子: 2013-08-01

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" );`

这里是我使用的jQuery代码,工作正常,但不知道在哪里放行?
我想要两个字段中的格式。

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 :-)

推荐答案

,因为您已经在datepicker中添加了其他选项,可以在其中添加。

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

尝试这个

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

这篇关于格式日期在jQuery UI datepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆