Open joseph-d opened 2 years ago
I notice that there is an inconsistency between the updated_at timestamp and regular date fields. Updated at is stored as UTC timestamp but date fields are stored as the timestamp in the defined timezone.
To fix this we'd need to be aware of both situations. To make them consistent, I think would be a breaking change.
What I would suggest in the mean time is perhaps to make a custom date fieldtype that extends our native one, use that for the updated_at field, and you could override the parseSaved
method to ->setTimezone()
appropriately.
Ahh, it looks like I opened this in April, a few days after we switched from UTC to BST here in the UK. Now it's the end of October so we're about to go back into UTC again which means I won't notice this issue for another 5 months. But at least now I have a plan for how I'll deal with it as April approaches next year - thanks!
This is related: https://github.com/statamic/cms/pull/8636#discussion_r1310047473
Bug description
I created a new collection called Tests with a blueprint which contains a time-enabled date field called updated_at.
Creating an entry within this collection just now produces a timestamp of
1649151537
which is equal to2022-04-05 09:38:57 UTC
. In the collection list, this shows as2022-04-05 09:38
as follows:However, because my
config/app.php
is set with'timezone' => 'Europe/London',
(which is UTC+1) I would expect this to show in the collection list as2022-04-05 10:38
Indeed, running
Carbon::now()
outputs2022-04-05 10:39:19.161282 Europe/London (+01:00)
because it's taking the timezone setting inconfig/app.php
into account and obviously a minute has passed since I wrote the above 2 paragraphs.How to reproduce
Create an entry in the collection by entering only the title and letting Statamic fill in the
updated_at
timestamp itself.View the entry in the list, enabling the
Updated at
field using theDisplayed Columns
buttonThe time displayed under
Updated at
will be the server time (usually UTC) and will not be taking the Laravelconfig/app.php
timezone setting into account.Logs
No response
Versions
Installation
Existing Laravel app
Antlers Parser
runtime (new)
Additional details
As far as I'm aware, having the server set on UTC is standard practice so I do not believe I'm doing anything fancy.