WordPress sets the php timezone to UTC for internal calculations. So at 4pm PST, date()
will be producing a date that reads 10pm UTC. Hence the event is considered past.
There are two ways to resolve this.
-
(The preferred method) Store dates in the database in UTC. Handle all date calculations in UTC, and convert to the desired timezone on output (frontend and back).
-
Use
date_i18n()
for creating the date to query (as this will set the date according to your blog timezone).
Related Posts:
- datetime picker, timestamps and meta queries
- ACF datepicker meta_query Compare Dates in m/d/Y g:i a – Not in Ymd Format
- Use meta_query to display events by date in custom field
- Query by custom dates in UNIX Time
- 2 weeks ago from meta query meta value
- Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
- WP_Query filter Posts by timestamp event (range start and end) and by month (next 12 month)
- Meta_query compare operator explanation
- meta_query with meta values as serialize arrays
- Nested meta_query with multiple relation keys
- meta_query ‘compare’ => ‘IN’ not working
- Use REGEXP in WP_Query meta_query key
- WP Query Args – Title or Meta Value
- Meta query with string starting like pattern
- compare meta_query in get_posts arguments
- How to query posts based on lat-lng coordinate as post meta?
- how to show posts that are missing a meta_value
- How to show all the associated posts with specific date of data metabox?
- WP_Query – show posts where meta value and user_email match
- WP Meta Query at depth 2
- Best way to Order Post in Home without a plugin
- WP_Query returns empty if meta_query has more than 7 values
- Is it possible to search for a string in posts OR postmeta?
- Extending WP Query: Custom geolocation meta values work, but tax_query breaks
- meta_query not working with the_content()
- WP_Query using meta_query with LIKE doesn’t return what it should
- Using custom field as ‘orderby’ value causing post grouping by publish date
- Use not custom fields in get_posts() meta_query?
- Filter posts/pages by user_role array
- WP_Query with MetaQuery issue
- WP_Query Posts by Metadata from Option Tree
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- Compare meta key separation
- WordPress meta_query not working
- Using orderby with 2 meta keys
- Is there any difference between below WP_Query code snippets?
- Get closest event where meta_key field is an array
- Using WP_Query to re-query and sort results using a date?
- WP_Query with meta_value_num and meta_query not paged correctly
- Post Query not working after updating to 4.1
- Orderby Meta Value and Query from Meta Query
- Return a single custom post from multiple meta queries
- Selecting posts older than the current Unix epoch timestamp
- The sorting of posts by a meta_query with two keys fails while separated as single queries it works
- WP_Query Sorting Posts by month … timeline effect
- Set right order for query that returns posts based on two custom fields
- Sorting: custom query with orderby meta_value_num THEN by title
- Sort posts in dashboard using custom field; also include posts where field isn’t set
- Passing conditional arrays to WP_Query() [closed]
- query post based on comparison
- WordPress Query Default Order if Meta Values Same?
- Time sort with meta_key using UNIX timestamp failing due to date differences
- Sort Posts with custom meta key by default which is currently set as optional
- Meta_query weird behaviour
- Why is WP_Query’s meta_query not filtering results?
- Including ‘cat’ => $cat breaks meta_query
- meta_query compare not doing what I want it to do
- Looking for a way to exclude frontpage and nav menu from query filter
- WP_Query with several meta_query-statements and order by meta_value
- Custom query (author is post_author or meta co_author) with Pagenavi pagination
- Creating Custom Query
- Query string form $_GET[‘value’] is not working as meta value in wp_query
- Can’t figure out query logic
- WP_Query orderby not working on custom post_type
- Wp query by 2 meta field – check if they exists / have value
- meta_query in wp_query not working as expected
- 294 Queries on Mainpage of WordPress
- Get posts by meta value except one post [closed]
- Get all user with both meta_value
- WP_Query by meta key not returning any posts
- Using ‘meta_query’ with the ‘pre_get_posts()’ hook disables searching for post titles
- WordPress extremely slow when using get_posts with multiple meta_query relations
- How do I have multiple metaqueries inside one wordpress query
- How to get all post_id and meta_value using meta_key in wp_postmeta table
- WP query with multiple custom meta not respecting orderby
- Get posts using multiple values from ACF checkbox as meta query wordpress
- WP Query – Show custom posts only if user contain some user meta
- How do I subquery with custom meta fields?
- get_post_meta bringing back results, but $wpdb->postmeta doesn’t
- Use meta query only 3 or more results?
- Why does wp_query only display the most recent post when using order ASC?
- Showing Counts on Comment List with Custom Query
- Custom query with custom filtering returning incorrect results
- WP Query returning all posts when Meta_query is null
- Display only posts with thumbnails
- Use value from meta key array for use in WP_Query
- WordPress – Optimize the Meta Query for 3 meta keys at a time
- Passing a variable containing a comma separated list of values in a meta-query
- Complicated `orderby` based on text in custom field
- meta_query post_date not returning results
- WP Query: orderby with one meta key, but multiple values
- How to use meta_query to retrieve posts from multiple custom post type
- How to get products with the same custom attribute like ean code
- WP_Query filtering in ACF field containing dates
- Multiple meta value orderby clauses in a WP_Query
- WP_Query: how to sort all posts by date when one category has a custom “date” field?
- get_meta_sql hook is not firing
- Post Query with Meta Query no longer working
- Problem making a WPQuery with ACF boolean
- Order by multiple custom fields within woocommerce hook for catalog ordering (woocommerce_get_catalog_ordering_args)