将语言更改为Bootstrap Datetimepicker [英] Change language to Bootstrap Datetimepicker

查看:89
本文介绍了将语言更改为Bootstrap Datetimepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Bootstrap的 datetimepicker ,它运行良好.问题是它是英语,我需要西班牙语,我读了一些帖子,但对我没有任何帮助.我的HTML定义为:

I'm using the datetimepicker of Bootstrap, it's working pretty well. The thing is that it's in english, and I need it in spanish, I had read some post but nothing works to me. my HTML is defined as:

<div class="form-group">
  <div class='input-group date datepicker' data-date-startdate="{{$student->middle}}" name="datepicker" >
    <input type='text' class="form-control placementT" id="fecha">
    <span class="input-group-addon">
      <span class="glyphicon glyphicon-calendar"></span>
    </span>
  </div>
</div>

在javascript中,我只有一个与datetimepicker相关的功能,这是:

In the javascript, I have only one function related with the datetimepicker, this is:

$('.input-group.date').each(function() {
  $(this).datetimepicker().on('dp.hide',function (ev) {
    //something
  });
});

那么,我应该添加些什么来将其更改为西班牙语?我已经读到这是与 locale.js 一起使用的,但是我可以在JavaScript中添加日期和月份的定义吗?

So, what should I add to change this to spanish?I had read that this is with locale.js but can I add the definition of days and months inside my javascript?

推荐答案

您需要添加语言环境,可以找到参考

You need to add locale, reference can be found here

对于西班牙语locale: 'es'

脚本

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/locale/es.js"></script>

西班牙语中的DateTimePicker

DateTimePicker in Spanish

$(document).ready(function(){
	$('.input-group.date').datetimepicker({
		locale: 'es',
	});
});

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css" />
<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.10.6/moment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/locale/es.js"></script>
<br>
<div class="form-group">
     <div class='input-group date datepicker' name="datepicker" >
          <input type='text' class="form-control placementT" id="fecha">
             <span class="input-group-addon">
                   <span class="glyphicon glyphicon-calendar">
                   </span>
            </span>
      </div>
</div>

这篇关于将语言更改为Bootstrap Datetimepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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