I figure that this is some timezone/UTC issue - but I can't quite figure it out.
I have setup Netlify CMS on my Gatsby website using the following config.yml
:
backend:
name: git-gateway
branch: master
publish_mode: editorial_workflow
media_folder: src/images/uploads
public_folder: /uploads
collections:
- name: "tourInfo"
label: "Tour Info"
files:
- file: "static/json/tours.json"
label: "Tours"
name: "tours"
fields:
- {label: "Tour", name: tour, widget: list, fields: [
{label: "Date", name: date, widget: "date"},
{label: "Spaces", name: spaces, widget: "number"},
{label: "Booked", name: booked, widget: "number", required: false} ]}
I've used this to create tour dates but on doing so there's inconsistencies:
On selecting a date through the CMS the date appears correct as above.
But then the date is saved as:
This is obviously inconsistent with the date which I input.
This behaviour is also consistent across all entered dates fetched via Gatsby on the front end:
[
{
"date":"2019-04-03T23:35:50.291Z",
"spaces":6,
"booked":6
},
{
"date":"2019-04-17T23:36:08.718Z",
"spaces":6,
"booked":null
},
{
"date":"2019-05-01T23:36:19.622Z",
"spaces":6,
"booked":null
},
{
"date":"2019-05-15T23:36:33.206Z",
"spaces":6,
"booked":null
},
{
"date":"2019-06-05T23:36:49.265Z",
"spaces":6,
"booked":null
},
{
"date":"2019-06-19T23:37:09.924Z",
"spaces":6,
"booked":6
}
]
They're all a day out.
I suspect this is some type of timezone issue? My locale is currently on BST.
Surely when working with the date
widget time shouldn't matter - why does Netlify even have to save a time? I'm only inputting a date.
How can I rectify this? So when I enter 2019/04/04 I get 2019/04/04?