PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Test if a date added with the Advanced Fields to a post has passed?

  1. Hey. I'm using a front-end GF to allow users to create a 'Project' custom post type. I'm using the Date field (from Advanced Fields, with the jQuery datepicker) on a couple of fields to allow users to set a project start and finish date.

    I can output these to my template fine. What I'd like is a way to test if the End Date field is before or after the current date - so I can display a 'Finished' or 'Still Active' message.

    This is the code that outputs the date to the template:

    <?php $project_enddate = get_post_meta($post->ID, 'project_enddate', true);
    if($project_enddate) : ?>
    <p><strong>End Date:</strong> <?php echo $project_enddate; ?></p>
    <?php endif; ?>

    BTW I am using dd/mm/yyyy format as I'm in the UK. If anyone has an idea on how to do this I'd be very grateful.

    Thanks

    Posted 11 years ago on Tuesday December 18, 2012 | Permalink
  2. Think I have answered my own question using PHP's strtotime.

    Code on Pastie

    Could probably be tidied up but seems to do what I need for now.

    Posted 11 years ago on Tuesday December 18, 2012 | Permalink
  3. David Peralty

    Glad you were able to figure it out. All my best!

    Posted 11 years ago on Tuesday December 18, 2012 | Permalink

This topic has been resolved and has been closed to new replies.