I'm using Bootstrap 3 datetimepicker in rails app. Here is my js file:
$(function() {
$('#datetimepicker').datetimepicker();
});
And I need to reformat date type into Year-Month-Day Time
I've tried
$(function () {
$('.datetimepicker').datetimepicker({
format: 'yyyy-mm-dd H:i'
});
});
But after adding format line script doesn't work. Any ideas?
UPD
</div>
<div class="form-group">
<%= label_tag :start_time, 'StartTime' %>
<div class="input-group date" id="datetimepicker">
<%= text_field :start_time, nil, class: 'form-control' %>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
</div>
here is using
I'm using Bootstrap 3 datetimepicker in rails app. Here is my js file:
$(function() {
$('#datetimepicker').datetimepicker();
});
And I need to reformat date type into Year-Month-Day Time
I've tried
$(function () {
$('.datetimepicker').datetimepicker({
format: 'yyyy-mm-dd H:i'
});
});
But after adding format line script doesn't work. Any ideas?
UPD
</div>
<div class="form-group">
<%= label_tag :start_time, 'StartTime' %>
<div class="input-group date" id="datetimepicker">
<%= text_field :start_time, nil, class: 'form-control' %>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
</div>
here is using
Share Improve this question edited May 30, 2015 at 9:22 Damir Nurgaliev asked May 30, 2015 at 8:39 Damir NurgalievDamir Nurgaliev 3615 silver badges20 bronze badges 1- try it as follows: $('#datepicker').datetimepicker({ format:'d.m.Y H:i' }); – Adnan Devops Commented May 30, 2015 at 8:44
3 Answers
Reset to default 3It worked for me as follows:
$('#datetimepicker').datetimepicker(
format: 'YYYY-MM-DD HH:mm'
)
You have to specify the dateFormat and timeFormat differently. Below is the code for reference:
$('#datetimepicker').datetimepicker({
dateFormat: "yy-mm-dd",
timeFormat: "HH:mm"
});
Both of the answers for this question didn't work for me. But this worked:
$('#datetimepicker').datetimepicker({
format: 'YYYY-MM-DD HH:mm'
})