javascript - jQuery UI 日期格式

标签 javascript jquery user-interface datepicker

我有以下带有 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/

相关文章:

javascript - 向右滚动模拟

jquery - 如何设置每个列表项相同的高度?

javascript - PrototypeJS 中的委托(delegate)()

windows - 被要求使用 Selenium 测试 Windows 桌面应用程序 UI——这怎么可能?

javascript - 使用 CasperJS/Javascript 提交表单?

javascript - 将相机 W.R.T 3d 对象放置在 Three.js 中

javascript - HTML 布局随 JS 或 CSS 变化?

javascript - AJAX Rails 4 中的 $.get 未执行

c++ - 以相反的顺序添加选项卡?

ios - scrollView 的 ContentInset