存储到postgresql数据库时,日期减少了1天

时间:2016-06-16 09:35:44

标签: node.js postgresql

在我的节点应用程序中,我使用postgresql作为我的数据库。我有一个字段名startdate。它在我的本地系统中运行良好。当我在数字海洋中托管我的应用程序时,日期减少了1天并存储到数据库......

我的模特:

"properties": {
    "startDate": {
      "type": "date",      
      "required": true,
      "postgresql": {
        "columnName": "startdate",
        "dataType": "date",
        "dataLength": null,
        "dataPrecision": null,
        "dataScale": null,
        "nullable": "YES"
      }
    }

假设我认为我将日期更新为"startDate":"2016-02-11".But its storing as 2016-02-10`。这对我来说很奇怪。请分享您的想法。提前谢谢..

编辑: 我的DigitalOcean当前日期如下:

Thu Jun 16 05:36:48 EDT 2016

我的当地日期如下:

Thu Jun 16 15:07:17 IST 2016

EDT和IST会有所作为吗?

1 个答案:

答案 0 :(得分:0)

您提到的时区差异绝对正确,因为IST是+0530 UTC且EDT是-0400 UTC,因此时差为0930小时。现在您可以做的是将postgre服务器的时区更改为UTC并以UTC格式保存日期或将数字海洋服务器的时区更改为UTC,以便仅在数据库中保存UTC日期。