Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Date (ymd) Comparison Bug
    primarykey
    data
    text
    <p>I am using a datepicker to store a unix / PHP timestamp that is selected by the user.</p> <p>I just noticed that in my attempt to print <code>$current_date</code> and compare it against <code>$_date_compare</code> ... FYI this is WordPress code, but the problem is not related to WordPress.</p> <p>So, that being said here's the snippet of relevant code:</p> <pre><code>$current_date = date('ymd'); $recentPosts = new WP_Query(); $recentPosts-&gt;query(array( 'category_name' =&gt; 'events', 'meta_key' =&gt; '_date_compare', 'meta_compare' =&gt; '&gt;=', 'meta_value' =&gt; $current_date, 'orderby' =&gt; 'meta_value', 'order' =&gt; 'ASC', 'posts_per_page' =&gt; 99 )); </code></pre> <p>For some reason, the result for Jan 01, 2005 is printing 50101 (leaving out the leading zero, which confuses me since I am using <code>date('ymd');</code> format for the date. </p> <p>Nevertheless, after some careful thought I realized that this is a non-issue. I'm trying to sort all events that have a HIGHER value than <code>$current_date</code>, yet the query is returning the Jan 01 2005 date in the HIGHER than <code>$current_date</code> query.</p> <p>At the time of this writing, today is <strong>110523</strong> in <code>date('ymd')</code> format. Why is <strong>50101</strong> being returned in my query that is checking for values that are <strong>higher</strong> than 110523?!</p> <p><em><strong>EDIT</em></strong> You can view the problem here: <a href="http://anasmadance.com/past-events-2/" rel="nofollow">http://anasmadance.com/past-events-2/</a> - The numbers printed just above the boxes are meant to be <code>ymd</code> formatted dates, which are correct for the early dates, but incorrect for the ones at the bottom of the page (which should be omitted from the query since they are past and therefore less than the value they are compared against)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload