我有以下带有 UI Datepicker 的脚本,但我需要日期作为我的 URL 中的参数。我似乎无法在 URL 中正确设置日期格式。带有日期的输入框是很好,但是日期没有出现在我的 URL 字符串中..
我需要将 dateText 变量格式化为“yyyy-mm-dd”
<script type="text/javascript">
jQuery(function() {
jQuery('#datepick').datepicker({ dateFormat: "yy-mm-dd" })({
onSelect: function (dateText, inst) {
window.location.href="reports?date=" + dateText;
}
})
});
</script>
谢谢你..
最佳答案
在你的 onSelect 中试试这个:
window.location.href="reports?date=" + $.datepicker.formatDate("yy-mm-dd", $(this).datepicker("getDate"));
关于javascript - jQuery UI 日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7672894/