[英]How to change language of bootstrap datetimepicker (not datepicker)
I am using Bootstrap latest version (4.2.1) along with jQuery latest version, I am using moment.js too along with jquery.datetimepicker 我正在使用Bootstrap最新版本(4.2.1)以及jQuery最新版本,我也在使用moment.js和jquery.datetimepicker
I have included a locale file for language but its not working at all. 我已经包含了语言的语言环境文件,但它根本不起作用。
I've tried almost every method to change datetimepicker English language to Chinese language. 我几乎尝试了将datetimepicker英语改为中文的所有方法。
$('#datetimepicker1').datetimepicker({locale:'zh-CN'});
If you look at the official doc , you can see that there is no zh-Cn. 如果你查看官方文档 ,你会发现没有zh-Cn。
You have 3 options if you want to use Chinese : 如果你想使用中文,你有3个选择:
- zh - Simplified Chinese (简体中文)
zh - 简体中文(简体中文)
- zh-TW - Traditional Chinese (繁體中文)
zh-TW - 繁体中文(繁体中文)
- ch - Simplified Chinese
ch - 简体中文
Also there is a function to use moment as your default formatter : 还有一个函数可以使用moment作为默认格式化程序:
$.datetimepicker.setDateFormatter('moment');
Below is the working code and this documentation is really helpful. 下面是工作代码,这个文档非常有用。
$.datetimepicker.setDateFormatter('moment');
$('#start_time').datetimepicker({
i18n:{
zh:{
months:[
'一月','二月','三月','四月',
'五月','六月','七月','八月',
'九月','十月','十一月','十二月',
],
dayOfWeek:[
"七", "一", "二", "三",
"四", "五", "六",
]
}
},
timepicker:true,
minTime:0,
minDate:0,
});
$.datetimepicker.setLocale('zh');
$('#start_time').datetimepicker({locale:'zh'});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.