【问题标题】:Bootstrap-datetimepicker formatting doesn't workBootstrap-datetimepicker 格式不起作用
【发布时间】:2013-11-14 11:08:04
【问题描述】:

我正在使用来自 tarruda 的 bootstrap-datetimepicker,我已经看到了这个 documentation 但是当我尝试使用 DD/mm/yyyy 格式化它时它不起作用,它给了我 DD/02/2013。我希望它像Mon Dec 02 2013。有什么帮助吗?
这是我的代码:

       <div class='input-append date' id='datetimepicker1'>
         <input name="bdate" date-format='DD/mm/yyyy' type='text' placeholder="Date"/>
         <span class='add-on'>
           <i data-date-icon='icon-calendar' data-time-icon='icon-time'>
              </i>
          </span>
        </div>
            <script type="text/javascript">
              $(function() {

                $('#datetimepicker1').datetimepicker({
                  pickTime:false,
                  format: 'DD/mm/yyyy'
                });                                             
              });

            </script>  

【问题讨论】:

    标签: twitter-bootstrap datepicker


    【解决方案1】:

    Bootsrap datetimepicker 使用 MomentJS,这里是Moment JS Doc的链接

    这是正确的代码。

    $('#datetimepicker1').datetimepicker({
         pickTime: false,
         format: 'ddd MMM DD YY'
    });
    

    【讨论】:

      【解决方案2】:

      bootstrap 没有日期时间选择器。这是 jquery UI 小部件! 看看这个http://api.jqueryui.com/datepicker/ 你的格式不对,试试

                  $('#datetimepicker1').datetimepicker({
                    pickTime:false,
                    format: 'dd/mm/yy'
                  });
      

      格式可以是以下几种的组合:

      d - day of month (no leading zero)
      dd - day of month (two digit)
      o - day of the year (no leading zeros)
      oo - day of the year (three digit)
      D - day name short
      DD - day name long
      m - month of year (no leading zero)
      mm - month of year (two digit)
      M - month name short
      MM - month name long
      y - year (two digit)
      yy - year (four digit)
      @ - Unix timestamp (ms since 01/01/1970)
      ! - Windows ticks (100ns since 01/01/0001)
      '...' - literal text
      '' - single quote
      anything else - literal text
      

      【讨论】:

      • 你真的访问了我提供的链接吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-15
      • 2014-02-05
      • 1970-01-01
      • 1970-01-01
      • 2021-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多