Closed AndrewMLeonard closed 2 years ago
The logic in the Events Calendar adds extra fields to an Events post. See the tribe_get_event_after
filter's results.
For the meeting on 30th April the date related fields are
[EventStartDate] => (string) "2022-04-30 11:00:00"
[EventEndDate] => (string) "2022-04-30 17:00:00"
[start_date] => (string) "2022-04-30 11:00:00"
[start_date_utc] => (string) "2022-04-30 10:00:00"
[end_date] => (string) "2022-04-30 17:00:00"
[end_date_utc] => (string) "2022-04-30 16:00:00"
[dates] => stdClass Object
[start] => Tribe\Utils\Date_I18n_Immutable Object
[date] => (string) "2022-04-30 11:00:00.000000"
[timezone_type] => (integer) 3
[timezone] => (string) "Europe/London"
[start_utc] => Tribe\Utils\Date_I18n_Immutable Object
[date] => (string) "2022-04-30 10:00:00.000000"
[timezone_type] => (integer) 3
[timezone] => (string) "UTC"
[start_site] => *RECURSION* start 2
[start_display] => *RECURSION* start 2
[end] => Tribe\Utils\Date_I18n_Immutable Object
[date] => (string) "2022-04-30 17:00:00.000000"
[timezone_type] => (integer) 3
[timezone] => (string) "Europe/London"
[end_utc] => Tribe\Utils\Date_I18n_Immutable Object
[date] => (string) "2022-04-30 16:00:00.000000"
[timezone_type] => (integer) 3
[timezone] => (string) "UTC"
[end_site] => *RECURSION* end 2
[end_display] => *RECURSION* end 2
[timezone] => (string) "Europe/London"
[duration] => (string) "21600"
[multiday] => (boolean)
[is_past] => (boolean)
[all_day] => (boolean)
[starts_this_week] => (NULL)
[ends_this_week] => (NULL)
[this_week_duration] => (NULL)
[happens_this_week] => (NULL)
In the wp_postmeta table the dates for post ID 34247 are already stored as required
Meta_key | meta_value |
---|---|
_EventStartDate | 2022-04-30 11:00:00 |
_EventEndDate | 2022-04-30 17:00:00 |
So we don't need any fancy logic to adjust the time!
The ebps_get_event_date()
function retrieves the post meta value and converts it to a PHP $datetime
value of 1651316400.
Converting this back to a date using $date = date('Y-m-d H:i:s', $datetime );
produces the value first thought of.
It's the wp_date()
function that's applying the clock time change.
We can resolve the problem by telling wp_date()
that the timezone is +00:00
- ie don't adjust the date.
This should now be fixed in v0.5.0 We should have spotted this problem back in November. This screenshot shows the wrong times https://github.com/bobbingwide/ebps-meetings/issues/1#issuecomment-977725661
To implement the fix:
The action of Saving the event clears the cache. The widget should then correctly display the times.
v0.5.0 now installed on ebps.org.uk
As you can see, the short code shows the time one hour later than the correct time