更改Bootstrap datepicker格式

时间:2016-06-13 16:31:08

标签: twitter-bootstrap datepicker

我正在使用Bootstrap datepicker,我想将其格式更改为' dd-mm-yyyy'但似乎没什么用。

$(document).ready(function () {
    $('#datepicker').datepicker({
       format: 'dd-mm-yyyy'
    });
});

我的剧本错了吗?

<html>
    <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="site/css/bootstrap.min.css" rel="stylesheet">
        <link href="site/css/style.css" rel="stylesheet">
        <link href="site/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css" rel="stylesheet">
        <script src="site/js/jQuery-1.12.3.js"></script>
        <script src="site/js/bootstrap.js"/></script>
    <script src="site/bootstrap-datepicker/dist/js/bootstrap-datepicker.js"/></script>
<script src="site/js/script.js"></script>

</head>
<body>
<!--body-->
<!--form-->
<div class="col-md-2">
<label for="date-depart">Date de départ</label>
<div class="input-group date" id="datepicker">
<input type="text" name="datedep" class="form-control datepicker" />
<span class="input-group-addon btn"><i class="glyphicon glyphicon-calendar"></i> </span>
</div>
</div>

4 个答案:

答案 0 :(得分:1)

试试这个

$(document).ready(function () {
$('#datepicker').datepicker({
   dateFormat: 'dd-mm-yyyy' 
});
});

答案 1 :(得分:0)

尝试使用此内部脚本标记

<script> 
$.fn.datepicker.defaults.format = "dd-mm-yyyy";
</script>

我遇到了和你一样的问题,这对我有用。

答案 2 :(得分:0)

border:5px solid #F7827B;

你应该给id =&#34; datapicker&#34;到您的输入字段,而不是.triangle-border1 { position:relative; padding:10px; margin:1em 0 1em; border:5px solid #F7827B; color:#333; background:#fff; -webkit-border-radius:10px; -moz-border-radius:10px; border-radius:10px; } .triangle-border1:before { content:""; position:absolute; bottom:-20px; left:40px; border-width:20px 20px 0; border-style:solid; border-bottom:0px white solid; border-bottom-color:transparent; border-left-color:transparent; border-right-color:transparent; border-top-color:#F7827B; } .triangle-border1:after { content:""; position:absolute; bottom:-10px; left:47px; border-width:13px 13px 0; border-style:solid; border-bottom:0px white solid; border-bottom-color:transparent; border-left-color:transparent; border-right-color:transparent; border-top-color:#FFF; } ,如下所示

<div class="input-group date" id="datepicker">
<input type="text" name="datedep" class="form-control datepicker" />

并将以下javascript内置于您的HTML

<div>

答案 3 :(得分:-1)

尽量不做引号。

format: dd-mm-yyyy