JavaScript Kendo 网格内的日期
JavaScript Date inside a Kendo Grid
我是 Web 开发的新手,在测试一些简单的东西时遇到了一个问题。
在这里,我在一个简单的数据库中有一些 Sql 日期时间格式的 UTC gtc 数据:
Database
所以我创建了一个 Kendo 网格来格式化数据(并在每个日期末尾附加 UTC)并且它正确显示:
Correct Result
当我尝试使用内置的Date类型的js将UTC日期时间转换为本地日期时间时出现问题:
Unexpected Result
出于某种原因,网格的第一行被转换为与其他行不同的时区。
这是我用来获取和格式化 table.
的代码
$scope.mainGridOptions = {
pageable: true,
editable: true,
sortable: true,
dataSource: {
pageSize: 5,
transport: {
read: function (e) {
$http.get('/GetScheduler')
.then(function success(response) {
e.success(response.data)
}, function error(response) {
alert('something went wrong')
console.log(response);
})
}
},
schema: {
model: {
fields: {
"id": {
editable: false
}
}
}
}
},
columns: [{ field: "id", title: "ID", width: "100px" },
{ field: "Current_Time", title: "Time of Request", template: '#= kendo.toString(kendo.parseDate(Current_Time), "dd/MM/yyyy h:mm")#' },
{ field: "Selected_Time", title: "Scheduled Time" , template: '#= Selected_Time+" UTC" #'},
{ field: "Description" },
{ command: "destroy", width: "100px" }]
};
您看到的似乎不是其他时区。由于日期原因,您似乎看到同一时区偏移了一个小时。
Since 1996, European Summer Time has been observed between 01:00 UTC (02:00 CET and 03:00 CEST) on the last Sunday of March, and 01:00 UTC on the last Sunday of October; previously the rules were not uniform across the European Union
我是 Web 开发的新手,在测试一些简单的东西时遇到了一个问题。 在这里,我在一个简单的数据库中有一些 Sql 日期时间格式的 UTC gtc 数据:
Database
所以我创建了一个 Kendo 网格来格式化数据(并在每个日期末尾附加 UTC)并且它正确显示: Correct Result
当我尝试使用内置的Date类型的js将UTC日期时间转换为本地日期时间时出现问题:
Unexpected Result
出于某种原因,网格的第一行被转换为与其他行不同的时区。 这是我用来获取和格式化 table.
的代码 $scope.mainGridOptions = {
pageable: true,
editable: true,
sortable: true,
dataSource: {
pageSize: 5,
transport: {
read: function (e) {
$http.get('/GetScheduler')
.then(function success(response) {
e.success(response.data)
}, function error(response) {
alert('something went wrong')
console.log(response);
})
}
},
schema: {
model: {
fields: {
"id": {
editable: false
}
}
}
}
},
columns: [{ field: "id", title: "ID", width: "100px" },
{ field: "Current_Time", title: "Time of Request", template: '#= kendo.toString(kendo.parseDate(Current_Time), "dd/MM/yyyy h:mm")#' },
{ field: "Selected_Time", title: "Scheduled Time" , template: '#= Selected_Time+" UTC" #'},
{ field: "Description" },
{ command: "destroy", width: "100px" }]
};
您看到的似乎不是其他时区。由于日期原因,您似乎看到同一时区偏移了一个小时。
Since 1996, European Summer Time has been observed between 01:00 UTC (02:00 CET and 03:00 CEST) on the last Sunday of March, and 01:00 UTC on the last Sunday of October; previously the rules were not uniform across the European Union