jQuery datepicker显示格式 [英] jQuery datepicker display format

查看:66
本文介绍了jQuery datepicker显示格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有带有日期字段(yy-mm-dd)的MySQL表.

I have MySQL table with date field (yy-mm-dd).

我有一个带有日期选择器的表格,可以对其进行编辑,并且效果很好.

And I have form with datepicker that edits it and it works fine.

但前端日期的BUT显示为mm-dd-yy,这可能会造成混淆.

BUT at the frontend date is displayed as mm-dd-yy and that can be confusing.

我希望带有日期选择器的字段将值显示为mm-dd-yy,但实际值应为旧格式(yy-mm-dd).

I'd like field with datepicker to display value as mm-dd-yy, but the actual value should be of the old format (yy-mm-dd).

如何做到这一点?

添加:我知道如何更改日期格式.我要分开显示值和实际值.就是这样.

Added: I know how to change format of date. I want separate displayed value and actual value. That's what it is all about.

推荐答案

jQuery UI Datepicker小部件带有 altField altFormat 选项,可用于设置辅助(表单输入,以所需的任何格式存储日期:

The jQuery UI Datepicker widget comes with altField and altFormat options that allow you to set a secondary (hidden if you want) form input to store the date in whatever format you want:

$( ".selector" ).datepicker({
    altField  : '#actualDate',
    altFormat : 'yy-mm-dd'
});

来源: http://jqueryui.com/demos/datepicker/#option-altFormat

这是一个演示: http://jsfiddle.net/MmKmq/

这篇关于jQuery datepicker显示格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆