根据本文档,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
引用:
关于jQuery datepicker "dateFormat"和 "altFormat"之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5619658/