Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Remove posts from query for events whose start date has passed

The date format is incorrect. I’m not sure how you have stored the date, but the format you’ve used in the query, date("MM d yy") outputs ‘MarMar 07 1212’.

It shouldn’t really matter that the input is being done by jQuery datepicker: The input should be in a pre-specified format – so you can interpret input it as a date (or preferably DateTime) object and then format that date in this format: 2012-03-07, which in php ‘format’ is 'Y-m-d'.

Alternatively you can store it as a time-stamp, if you are not bothered about 2038.

Finally be weary of using php date functions. WordPress sets the ‘internal’ timezone to UTC – its better to use WordPress functions which will account for the timezone of the blog.

Related Posts:

  1. Search custom post type by meta data
  2. Very slow query
  3. How to display liked posts of current user in wordpress?
  4. Filter query posts by the count of metas for a meta key
  5. Save default value for empty or missing post meta
  6. Grouping related postmeta data via SQL query
  7. Does meta_query work within get_posts array?
  8. How to show more than 5 posts?
  9. How to optimize my query filtering out unwanted data?
  10. mySQL query. ORDER BY meta_key
  11. get_posts() loop returns the same the_title() for each post
  12. Query metas (and not : query posts by metas)
  13. List all posts from past week grouped by sub-category
  14. Order posts by custom field DATE value
  15. How do I see the mysql query generated by get_posts( $args )?
  16. Issue with using add_rewrite_rule() for post querying custom fields
  17. Create Indexes for Slow Queries
  18. Query posts according to specific post meta values
  19. get_posts showing only 5 posts. (nopaging and posts_per_page -1 not working)
  20. Order by meta value pro first then meta value free in my search function
  21. pre saved posts query from db options table
  22. Re-sort get_posts query results
  23. get_post_meta with WP_query
  24. Declaring a var, placing it in a query and using the output of the query?
  25. Combining two meta_values within one row with query
  26. Can I include get_posts in this array?
  27. How can I get posts by 2 meta keys, prioritising one of them?
  28. Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
  29. Sort by postmeta on when searching
  30. Category_in return empty
  31. Use $wpdb->get_results with filter based on array
  32. What is the best way to query posts based on live data?
  33. Custom MySQL Query for Post and Post Meta
  34. Sort order in get_posts [closed]
  35. When should you use WP_Query vs query_posts() vs get_posts()?
  36. How to display SQL query that ran in query?
  37. How can I create a meta_query with an array as meta_field?
  38. Query multiple meta key values?
  39. How to Optimize WP site for millions of posts
  40. order by numeric value for meta value
  41. Get the ID of the latest post
  42. How to get comments by post ID?
  43. WP_Query vs get_posts
  44. Differences between wpdb->get_results() and wpdb->query()
  45. Is there a way of increasing the speed of this query?
  46. meta_query: using BETWEEN with floats and/or casting to DECIMAL
  47. Get all image from single page using this query
  48. How can I query all users who registered today?
  49. Get Terms by IDs with IDs order
  50. Reversing the order of posts AFTER the query is performed
  51. what are the numbers between curly brackets in search query
  52. simple sql query on wp_postmeta very slow
  53. Using WordPress public query variables
  54. How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
  55. When/why does ‘$query->get( ‘tax_query’ );’ return empty?
  56. How to get link and title of next and previous post on single page
  57. Create pagination and order according to alphabet
  58. wpdb get posts by taxonomy SQL
  59. How to List Events by Year and Month Using Advanced Custom Fields?
  60. What is the most efficient way of querying posts based on visits and date for current day?
  61. Is there any difference between hooks posts_where with posts_join and posts_search performance wise?
  62. How to organize and cache additional data associated with terms?
  63. wordpress query – orderby child post date
  64. How many WordPress SQL Queries per page?
  65. How to display Section for certain time
  66. Add multiple value to a query variable in WordPress
  67. Custom query_var causes displaying posts archive on front page
  68. How to know if get_posts() failed?
  69. Slow wp_enqueue_media()
  70. Multipart/formatted MySQL query problem
  71. Custom Queries: Joining On Meta Values From Two Custom Post Types
  72. What is the most efficient way of implementing a favorite post system?
  73. Query Custom Meta Value with Increment
  74. Remove [gallery] shortcode altogether
  75. Compare two numeric custom fields
  76. wp_dropdown_categories with multiple select
  77. Advanced Custom Fields – Query Efficiency
  78. Why does get_the_time(‘F j’) return November 30 for all posts?
  79. Get posts by meta data OR title
  80. Query by one meta_key and sort by another (possibly NULL value)
  81. How to tune search argument in WP_Query to show only exactly the same results?
  82. Custom query filter not working on woocommerce category page
  83. How to delete a transient on post/page publish?
  84. WPDB Multiple site’s posts and get featured images
  85. query multiple taxonomy and show post count
  86. Search Terms – Querying on either description__like OR name__like in the same Term Query?
  87. Query & Sort Comments by custom comment meta
  88. How to get my loop to pull posts into three columns
  89. How to display lastest post date in the homepage?
  90. Custom $wpdb Query for Custom Post Type by Category
  91. Limit number of pages in pagination
  92. Get a user’s most recent post title
  93. Categories and products in random order
  94. add_query_arg() XSS Vulnerability
  95. Count user posts by user ID, Post type and Post status
  96. Can’t pass table to $wpdb->prepare
  97. Query set using tax_query with relation ‘OR’ modifies category object?
  98. $query->query_var[‘post_type’] not set for pages
  99. is_archive() doesn’t work on public query var archive pages?
  100. How to extract all ID variables from a query string?
Categories query Tags get-posts, post-meta, query
How to get future ID for post which haven’t been created yet?
Second Custom Post Type Archive

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress