So I am making changes to a clients website and currently they have an events post type with some custom fields that allow them to set an events end date/time and the events timezone.
The custom fields setup:
- Start Date and Time: text input / saves as php format
U
- End Date and Time: text input / saves as php format
U
- Timezone: select field / saves as string (e.g.
GMT
/BST
)
And then on the front end their current wp_query is:
$events_query = new WP_Query([
'post_type' => 'events',
'meta_key' => 'start_date_and_time',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => [
[
'key' => 'end_date_and_time',
'value' => date('U'),
'compare' => '>=',
'type' => 'NUMERIC'
]
]
]);
But this is not taking into account the timezone set in the backend compared to the timezone of the user.
Any help would be great.
Thanks.