我正在使用此jquery插件將日期轉換爲文本框。此代碼的默認格式是12/12/2013。但我需要將格式轉換爲2013-12-12,因爲我已經保存的數據庫日期數字是這種格式。所以我需要比較12/12/2013和2013-12-12。由於它們的格式不同,我無法比較它們。那麼如何將2013年12月12日的格式轉換爲2013-12-12。將日期格式12/12/2013轉換爲2013-12-12
<!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.3/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.3/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>
您的意思是:$(「#datepicker」).datepicker(「option」,「dateFormat」,「yy-mm-dd」); –
@亞歷膠帶,是的,這是錯字,感謝您的指點。 –
+1爲您的答案! –