jQuery Datepicker dateformat

时间:2012-11-20 22:35:17

标签: jquery datepicker

使用Datepicker的默认示例:

<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>jQuery UI Datepicker - Default functionality</title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />
    <script>
    $(function() {
        $( "#datepicker" ).datepicker();
    });
    </script>
</head>
<body>

<p>Date: <input type="text" id="datepicker" /></p>


</body>
</html>

如何更改日期方式显示为yy-mm-dd?

谢谢:)

2 个答案:

答案 0 :(得分:2)

添加dateFormat作为选项 -

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

答案 1 :(得分:1)

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

取自API文档:http://docs.jquery.com/UI/API/1.8/Datepicker