【问题标题】:JavaScript Date inside a Kendo Grid剑道网格中的 JavaScript 日期
【发布时间】:2020-11-05 03:53:21
【问题描述】:

我是 Web 开发的新手,在测试一些简单的东西时遇到了一个问题。 在这里,我在一个简单的数据库中以 UTC gtc 的 Sql 日期时间格式保存了一些数据:

Database

所以我创建了一个 Kendo Grid 来格式化数据(并在每个日期的末尾附加 UTC),它正确显示: Correct Result

当我尝试使用js的内置日期类型将UTC日期时间转换为本地日期时间时出现问题:

Unexpected Result

由于某种原因,网格的第一行被转换为其他行的不同时区。 这是我用来获取和格式化表格的代码。

 $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" }]
    };

【问题讨论】:

    标签: javascript sql angularjs kendo-ui kendo-grid


    【解决方案1】:

    您看到的时区似乎没有变化。由于日期的原因,您似乎看到同一时区偏移了一个小时。

    自 1996 年以来,欧洲夏令时在 3 月最后一个星期日 01:00 UTC(欧洲中部时间 02:00 和 03:00 CEST)和 10 月最后一个星期日 01:00 UTC 之间实行;以前,整个欧盟的规则并不统一

    Check here for more information.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多