WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom meta box with a datepicker. The datepicker outputs 2013-01-17 10:00 in my database for an event that is 01-17-2013 at 10pm PST.

$eventlist = new WP_Query(array(
    'post_type' => 'events',
    'posts_per_page' => 5,
    'order' => 'asc',
    'orderby' => 'meta_value',
    'meta_key' => 'datetime',
    'meta_query' => array(
            'key' => 'datetime', // Check the start date field
            'value' => date("Y-m-d H:i:s"),  
            'compare' => '>=', 
            'type' => 'DATETIME' 

The issue is, at 4pm PST the event disappears, leading me to believe somewhere it is thinking its UTC and making the post go bye bye. Where would i Find this issue and how can i solve it?

share|improve this question

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.

  1. (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).

  2. Use date_i18n()for creating the date to query (as this will set the date according to your blog timezone).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.