On WordCamp sites, the session times have been saved as a unix timestamp in UTC, regardless of the site’s timezone. We’ll be fixing this across all WordCamp sites, but this requires changing the session time for all sessions on all sites to include the timezone offset. This should not affect organizers or attendees, but anyone using the timestamp directly from the API will see a change.
You can see how we’re fixing this on GitHub, and if you have any input, please leave a reply. There was also some discussion on slack.
What’s the problem?
We were saving timestamps as if they were in UTC, regardless of the site’s timezone, which lead to technically-incorrect timestamps.
For example, if you have a site in EST, and you save a session for March 1st at 4pm, it will actually save it as “March 1st 2020 16:00 UTC”, which is not actually when that talk is. In most places this has been fine, because php’s date
also assumed UTC, but as of WordPress 5.3, we have timezone-aware date functions. Additionally, these timestamps are causing headaches for using these values outside of PHP, like in JavaScript (for gutenberg) or 3rd parties developing apps.
Do I need to do anything?
If you’re an organizer, attendee, or someone else who just uses the WordCamp sites, no 👍🏻
If you have an app that uses the WordCamp REST API to get session info (including the time), you might need to update your code.
For apps using the the v1 endpoint still, ex wp-json/posts/?type=wcb_session
, the legacy timestamp will still be returned (but please update to v2 😉).
For the current endpoints (ex wp-json/wp/v2/sessions
), the meta._wcpt_session_time
value will now be the correct timestamp. If you’re manually calculating a timezone offset to display the “right” time, you can remove that code. If you can’t change right away, add ?wc_session_utc=true
to your requests, and it will return the legacy timestamp.
I want to run the script to convert these times next week (Feb 12th), and these values will change immediately. You can add the legacy query to your request now, and it will not do anything until the change is made.
+make.wordpress.org/community
So, it was saving the wrong timestamp because of incorrect time zone assumptions and this is correcting it to be the correct UTC time? If so, I approve. Best to get everything on the same page. 👍
yeah, exactly 🙂
+make.wordpress.org/community