[英]How is Bootstrap / Moment DateTimePicker failing to display the correct 24 hour format?
I've been plugging away at this for too long and I cannot see where the formatting for Bootstrap's datetimepicker control is being overridden. 我已经为此插了太长时间了,我看不到Bootstrap的datetimepicker控件的格式在哪里被覆盖。
The Bootstrap DTP uses Moment.js behind the scenes to format its time picker. Bootstrap DTP在后台使用Moment.js格式化其时间选择器。 The JS code looks like this:
JS代码如下所示:
selector.find(".datepicker").each(function() {
var $that = $(this);
$that.datetimepicker({
sideBySide: true,
useCurrent: false,
minDate: new Date(1910, 1, 1)
});
$that.children("input").on("focus", function() {
$that.data("DateTimePicker").show();
});
});
Nothing appears too complex there and the formatting in the HTML looks similarly simple: 没有什么看起来太复杂了,HTML的格式看起来也很简单:
@Html.EditorFor(x => x.DateTime, new { @dateFormat = "DD/MM/YYYY HH:mm", @mandatory = true })
However when the model is bound to the view and the JS iterates over the inputs, the times displayed go from 24 hour (eg 14:00
) to 12 hour (ie 02:00
). 但是,当模型绑定到视图并且JS对输入进行迭代时,显示的时间从24小时(例如
14:00
)到12小时(即02:00
)。
I'm convinced this has to do with moment.js integration and very likely its handling of timezones but I can't see where I might apply different settings. 我坚信这与moment.js集成及其对时区的处理很有关系,但是我看不到在哪里应用不同的设置。 Suggestions would be more than welcome at this point.
在这一点上,建议将是非常受欢迎的。
Try this 尝试这个
$that.datetimepicker({
format: 'DD/MM/YYYY HH:mm',
sideBySide: true,
useCurrent: false,
minDate: new Date(1910, 1, 1)
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.