dateFormat option for DateBox does not work?

白昼怎懂夜的黑 提交于 2019-12-11 01:17:31

问题


I am trying to get the dateFormat option of jtsage's jQuery-mobile DateBox plug-in to work. I have the following code in an HTML document:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
    <link rel="stylesheet" type="text/css" href="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.min.css" />
    <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
    <script src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.core.min.js"></script>
    <script src="http://dev.jtsage.com/cdn/datebox/latest/jqm-datebox.mode.calbox.min.js"></script>
    <script src="http://dev.jtsage.com/cdn/datebox/i18n/jquery.mobile.datebox.i18n.en_US.utf8.js"></script>
</head>
<body>
    <div data-role="page">
        <input type="date" name="date" data-role="datebox" data-options='{"mode":"calbox","dateFormat":"%b %d"}' />
    </div>
</body>
</html>

There are two parts to my question:

  1. The value of dateFormat is based on this page: http://dev.jtsage.com/jQM-DateBox/demos/api/dateformat.html. I am expecting to choose a date, and it would be displayed in the dateFormat, i.e. Jan 2, Mar 29, etc. Is this correct, or is it supposed to be used differently? With this code, selecting a date results in a format like 1/2/2012, 3/29/2012, etc.

  2. The value we are storing in the database vs. what we want the date picker to display is different, i.e. 2012-01-02 => Jan 2, Jan 2 => 2012-01-02. Is this possible?

Thanks in advance.


回答1:


http://jsfiddle.net/PGFxZ/3/ in this fiddle change your dateformat to '%b/%d', you will get the date format like this jan/01....etc..



来源:https://stackoverflow.com/questions/11724670/dateformat-option-for-datebox-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!