UTC时间没有转换为bootgrid的本地?
问题描述:
我有一个表来显示bootgrid内部的时间戳。此时间戳使用NOW()创建,并以UTC格式创建。我希望在显示bootgrid内部时将其显示为本地时间。表头如下所示。UTC时间没有转换为bootgrid的本地?
<th data-column-id="ts" data-header-align="center" data-align="center" data-order="desc" data-converter="datetime">Upload Date</th>
我写了一个转换器日期时间使用momnet
converters: {
datetime: {
from: function (value) { return moment(value); },
to: function (value) { return moment(value).local().format("lll"); }
}
}
转换为本地时间,但问题是,它仍然是在UTC,而不是在本地time.How解决这一问题显示?
答
var now = new Date();
var now_utc = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());