We are using the date field on a custom post type that we want to default to today's date by setting "default:" "now".
Unfortunately this appears to default to UTC 0 rather than the timezone we are in (+10), and therefore show's yesterday's date for the first 10 hours of our day.
How can we set the date function to default to our or a sepcific timezone?
Hello @prismic_user, Dates are localized based on a user's time zone so you will always see the date relevant to you. In the API you'll see the date GMT.
Hi Pau, the issue is that configuring the Date field to default to the current date ("default": "now") does not default to the user's time zone.
For example, when a content author in UTC+10 creates a new document at 9am local time, the date defaults to the previous day (presumably because it is the previous day in UTC+0). This is an issue for us, because we have a daily blog post that is created at 9am each day, and the content author is forced to manually change the date.
Is it possible to set the time zone the Date field defaults to?
Thanks for detailing your use case. We've concluded that there's an issue with this field data. We've logged it in the issue tracker, and we'll update this same thread when we have a solution.
Hi @Pau I've also encountered issues with the Timestamp field: no matter the time zone where my content is created (we're on the East Coast of the US and that's reflected in the time field GUI in Prismic), it comes through the GraphQL API as z+0000, so we have to adjust our dates/times to UTC for them to display correctly on our front end. Is this the same problem?
Thanks @Phil,
The surprising behavior was that the time given in UTC was numerically identical to the time set in local time in the editor so, if the time was set as 12:30PM UTC-4 it would come in as 12:30PM UTC, and display on our front-end as 8:30AM.
Can you check how it appears in your API Browser? If it appears differently here than in your front-end then there's some conversion being done in your web app.
We're using GraphQL on our project. The date appears the same on the front and and in the GraphQL query results (the UTC time i.e. 12:30pm - 2:30pm in our case), but differently in the editor (UTC-4, i.e. 8:30am - 10:30am).