Eonasdan Bootstrap datetimepicker格式 [英] Eonasdan Bootstrap datetimepicker format

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

问题描述

如何在bootstrap 3 datetimepicker中设置格式.我想要的格式为"dd/MM/yyyy hh:mm",但我不想使用"AM"和"PM".对于这种语言,我可以在这里使用.下面的小提琴我该怎么做?

How to set a format in bootstrap 3 datetimepicker. I want the format "dd/MM/yyyy hh:mm" and I dont want "AM" and "PM". For that in which language I can use here. The following fiddle How can I do this?

http://jsfiddle.net/Eonasdan/0Ltv25o8/

$('#datetimepicker1').datetimepicker({
 
    format : "dd/MM/yyyy hh:mm",
    
});

<!-- padding for jsfiddle -->
<div class="row">
    <div class="col-md-12">
        

        <div class="form-group">
            <div class="input-group date" id="datetimepicker1">
                <input type="text" class="form-control" />	<span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span></span>
            </div>
        </div>        
    </div>
</div>

推荐答案

$('#datetimepicker1').datetimepicker({format : "DD/MM/YYYY hh:mm"});
$('#datetimepicker2').datetimepicker({format : "DD/MM/YYYY hh:mm"});

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js"></script>  
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css" rel="stylesheet"/>
</head>
<br/>
<!-- padding for jsfiddle -->
<div class="row">
    <div class="col-md-12">
         <h6>datetimepicker1</h6>

        <div class="form-group">
            <div class="input-group date" id="datetimepicker1">
                <input type="text" class="form-control" />	<span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span></span>
            </div>
        </div>
         <h6>datetimepicker2</h6>

        <input type="text" class="form-control" id="datetimepicker2" />
    </div>
</div>

我不确定您的机器为什么不工作,使用dd/MM/yyyy hh:mm会给出输出We/04/yyyy 08:43.如果要使输出为例如01/03/2015 12:01,则需要设置format : "DD/MM/YYYY hh:mm".有关格式选项的更多信息,请参阅 momentjs 文档.

I'm not sure why yours isn't working, using dd/MM/yyyy hh:mm gives the output We/04/yyyy 08:43. If you want the output to be for example 01/03/2015 12:01 you need to set format : "DD/MM/YYYY hh:mm". For more information on format options take a look at the momentjs documentation.

查看更新的 jsfiddle

您需要确保包含datetimepicker需要工作的所有必需的css和js文件.您还需要先加载momentjs和jquery.请参阅代码段.

You need to make sure that you include all of the necessary css and js files that the datetimepicker needs to work. You also need momentjs and jquery to load first. See code snippet.

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

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