Date and Time Picker Field
incorrect time is being displayed. (3 posts)

  1. bobdobbs
    Posted 2 years ago #

    I'm using wordpress 3.9.1, ACF 4.3.8 and version 2.0.14 of the 'date and time picker' extension.

    I'm created a custom post type, and used ACF and this extension to create a custom field for date and time.

    I've created some events, and selected dates and times for them.

    In the single pages for the event, the actual time and date I've chosen isn't being published. No matter what time and date I pick, the displayed time is always the time that I actually loaded the page.

    I have chosen this time and date for none of my posts.

    My loop looks like this:

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    $args = array(
      'post_type' => 'myCPT'
    ) ;
    $my_query = new WP_Query($args) ;
    if ($my_query->have_posts()) : ?>
      <?php $count =0  ?>
      <div >
              <div class="day">
    	    <?php $date = get_field('eventDate');  ?>
    	    <p><?php echo date('l \t\h\e jS M Y')  ?></p>
    	    <p><?php echo date('hia')  ?></p>
          <?php endwhile; ?>
    <?php endif;  ?>

    How do I display the actual date/time that I picked?


  2. robmaurizi
    Posted 2 years ago #

    You need to pass the PHP date() method an optional timestamp, otherwise it defaults to right now:

    <p><?php echo date('l \t\h\e jS M Y', $date)  ?></p>
    	    <p><?php echo date('hia', $date)  ?></p>

    Note, the above assumes that you $date var is in fact a timestamp. If it's a string, you'll need to use $timestamp = strtotime($date); and pass $timestamp into the date() function.

  3. Per Søderlind
    Plugin Author

    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Date and Time Picker Field
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic