Reputation: 267
I am experimenting with locale option of eonasdan datetimepicker but noticed a strange behavior.
Case 1:
Browser lang : en and html is
<div class="container">
<div class="row">
<div class='col-sm-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker2'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#datetimepicker2').datetimepicker({
locale: 'ru'
});
});
</script>
</div>
The datetimepicker input have no issues it displays the 'ru' calendar with the date.
Case 2:
Browser lang: ru and the same html as above. The datetimepicker shows the 'ru' calendar but the input value is empty.
Does any one noticed this behavior? Ipon changing the browser lang to something other than english the picker value becomes empty.
Upvotes: 0
Views: 2866
Reputation: 6336
https://github.com/Eonasdan/bootstrap-datetimepicker/issues/530
To switch locales you can load the moment locale that you are interested at and then set the language option of the component. It will fetch all the needed localized strings from moment library.
Upvotes: 0
Reputation: 3479
Try this
<br/>
<div class="row">
<div class="col-md-12">
<h6>Datetimepicker</h6>
<div class="form-group">
<div class="input-group date" id="datetimepicker">
<input type="text" class="form-control" /> <span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span></span>
</div>
</div>
</div>
JavaScript
$('#datetimepicker').datetimepicker({
locale: 'ru',
});
Upvotes: 0