Title: wrong date in post loop
Last modified: July 3, 2020

---

# wrong date in post loop

 *  Resolved [kiccokeys](https://wordpress.org/support/users/kiccokeys/)
 * (@kiccokeys)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/wrong-date-in-post-loop/)
 * Hello,
    as I try to loop the upcoming events like this:
 *     ```
       <?php
         $loop = new WP_Query( array(
           post_type' => 'mep_events',
           'posts_per_page' => 3
           )
          );
       ?>
   
       <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
           <h2><?php the_title(); ?></h2>
           <span><?php do_action('mep_event_date'); ?></span>
       <?php endwhile; wp_reset_query(); ?>
       ```
   
 * what i get is that, instead of event date, I get CURRENT date.
    Is there something
   i’m doing wrong?
 * Thanks a lot, regards.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [kiccokeys](https://wordpress.org/support/users/kiccokeys/)
 * (@kiccokeys)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/wrong-date-in-post-loop/#post-13068703)
 * I solved like this (if can be helpful)
 *     ```
       //inside the loop
       $date = get_post_meta($post->ID, 'event_start_date', true); if($date != ''){echo date("j F Y", strtotime($date));
       $time = get_post_meta($post->ID, 'event_start_time', true); if($time != ''){echo date("H:i", strtotime($time));} 
       //inside the loop
       ```
   
 *  Plugin Contributor [Md. Abdullah Al Mahim](https://wordpress.org/support/users/aamahin/)
 * (@aamahin)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/wrong-date-in-post-loop/#post-13073047)
 * Instead of using date function, you can use get_mep_datetime($date,$type) this
   function to display the correct date because date returns the server DateTime.
 * It will display the date according to wp date settings
    echo get_mep_datetime(
   $date,’date’);
 * It will display the date as text according to wp date settings
    echo get_mep_datetime(
   $date,’date-text’);
 * It will display the date & time according to wp date settings
    echo get_mep_datetime(
   $date,’date-time’);
 * It will display the date text as text according to wp date settings
    echo get_mep_datetime(
   $date,’date-time-text’);
 * Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘wrong date in post loop’ is closed to new replies.

 * ![](https://ps.w.org/mage-eventpress/assets/icon-128x128.png?rev=2252722)
 * [Event Booking Manager for WooCommerce](https://wordpress.org/plugins/mage-eventpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mage-eventpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mage-eventpress/)
 * [Active Topics](https://wordpress.org/support/plugin/mage-eventpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mage-eventpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mage-eventpress/reviews/)

## Tags

 * [date](https://wordpress.org/support/topic-tag/date/)
 * [events](https://wordpress.org/support/topic-tag/events/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * 2 replies
 * 2 participants
 * Last reply from: [Md. Abdullah Al Mahim](https://wordpress.org/support/users/aamahin/)
 * Last activity: [5 years, 9 months ago](https://wordpress.org/support/topic/wrong-date-in-post-loop/#post-13073047)
 * Status: resolved