keystonejs/keystone-classic

Datetime field type adds 5 hours to data

Open

#4,082 opened on Mar 9, 2017

View on GitHub
 (9 comments) (0 reactions) (0 assignees)JavaScript (2,288 forks)batch import
help wantedneeds confirmation

Repository metrics

Stars
 (14,656 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Expected behavior

When converting a JavaScript Datetime object to an ISOString and then uploading to a KeystoneJS app, I expect the get the same time string back from the server.

Actual behavior

The Datetime string returned by the server has 5 hours appended to the value.

Steps to reproduce the behavior

  1. I create a model with a Datetime field like so: reportGenerated: { type: Types.Datetime, default: Date.now }

  2. Below is an example of an object with JavaScript Date objects:

Image 1

  1. I use an API, similar to the API Gist by Jed or the File and Image API Guide. That API will reject JavaScript Date objects, but will accept an ISO string. Here is an example of the same object with it's Date objects converted to ISO strings using Date.toISOString() in preparation of uploading to the KeystoneJS server:

Image 2

  1. Send data to the server succeeds. However, when retrieving the same data from the server, the ISO strings have 5 hours added to them:

Image 3

Contributor guide