更改jquery日期选择器格式

时间:2014-01-24 14:17:14

标签: jquery

Hello以下是jquery日期选择器代码。它以格式显示日期:

day/month/year

如何将此格式更改为该格式?

day-month-year

完成Jquery代码:

<!doctype html>
<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.10.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/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>

1 个答案:

答案 0 :(得分:1)

有很多关于该主题的帖子。

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

此处提供更多常规信息:

jQuery UI DatePicker - Change Date Format