jQuery datepicker "dateFormat"和 "altFormat"之间的区别

标签 jquery jquery-ui date datepicker

根据本文档,http://jqueryui.com/demos/datepicker/#option-altFormat

我可以设置不同的日期格式供用户查看,以及实际发送到服务器的不同格式。

但是,两者似乎显示相同的格式。

这是我的代码:

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

而且,我希望用户看到 yy-mm-dd 格式,并使用我的发布请求将时间戳发送到服务器。我已经切换了 altFormat 和 dateFormat 的值,但要么在两个(文本框和 $_POST)中都得到 yy-mm-dd,要么在两者中都得到时间戳。

有解决办法吗?

最佳答案

我想你一定要读一下这篇文章

The dateFormat to be used for the altField option. This allows one date format to be shown to the user for selection purposes, while a different format is actually sent behind the scenes. For a full list of the possible formats see the formatDate function

引用:

http://api.jqueryui.com/datepicker/#option-altField

关于jQuery datepicker "dateFormat"和 "altFormat"之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5619658/

相关文章:

sql - 如何计算两个日期的持续时间?

javascript - load() 和 getscript() 并不总是有效

javascript - 如何设置上传的图片?

java - 如何使用 ucanaccess 获取查询中的行数

jquery-ui - jQuery的toggleClass和slideToggle

jquery - 向 jQuery UI Slider 添加文本比例

javascript - 根据条件打开日期选择器

c++ - 将 std::chrono::milliseconds 转换为 ISO 8601 字符串

PHP日期问题

jQuery 表单验证,仅允许 .EDU 电子邮件地址