Date field issues

I did find this with REST

Request:
POST: http://localhost:1337/preferred-date-times
{
    "date": "2021-05-10T05:00:00.000Z",   <== 05:00:00.000Z 
    "time": "afternoon"
}
Reponse:
{
    "date": "2021-05-08",  <== Two days behind
    ...
}

In Db: 2021-05-09



Request:
{
    "date": "2021-05-10T06:00:00.000Z",   <== 06:00:00.000Z
    "time": "afternoon"
}
Response:
{
    "date": "2021-05-09",  <== One day behind
    ...
}

In Db: 2021-05-10

So somehow 30 hours is being subtracted from any Date Field I send to the Strapi API. Also it turns out for date fields I can submit full date times not just dates. This does not work in GraphQL.

This only occurs with Date fields

Request:
{
    "mydate":     "2021-05-10T06:00:00.000Z",    <==Identical date times
    "mydatetime": "2021-05-10T06:00:00.000Z"
}

Response:
{
    ...
    "mydate":     "2021-05-09",                     <== One day behind
    "mydatetime": "2021-05-10T06:00:00.000Z",       <== Correct
}

I tested the above with a clean install of 3.4.6. I don’t know why this is happening shrug

1 Like