javascript - Bootstrap3 datetimepicker DATE format rails - Stack Overflow

I'm using Bootstrap 3 datetimepicker in rails app. Here is my js file:$(function() {$('#datet

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
Add a ment  | 

3 Answers 3

Reset to default 3

It 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'
})

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745566264a4633410.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信