WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. bobdobbs
    Member
    Posted 2 months 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. ]

    <?php
    $args = array(
      'post_type' => 'myCPT'
    ) ;
    $my_query = new WP_Query($args) ;
    
    if ($my_query->have_posts()) : ?>
      <?php $count =0  ?>
      <div >
    
    <ul>
    <li>
              <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>
    	  </div>
    	</li>
          <?php endwhile; ?>
        </ul>
      </div>
    <?php endif;  ?>

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

    https://wordpress.org/plugins/acf-field-date-time-picker/

  2. robmaurizi
    Member
    Posted 2 weeks 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 Soderlind
    Member
    Plugin Author

    Posted 1 week ago #

Reply

You must log in to post.

About this Plugin

About this Topic