Skip to content

Instantly share code, notes, and snippets.

@barbwiredmedia
Created November 15, 2013 00:45
Show Gist options
  • Save barbwiredmedia/7477228 to your computer and use it in GitHub Desktop.
Save barbwiredmedia/7477228 to your computer and use it in GitHub Desktop.
Wordpress Working with time datepicker in javascript and ACF meta date. Reformat time for use by persons and show different content depending on if the date has passed.
<?php
// http://php.net/manual/en/function.date.php
//get the time from the ACF time picker see php.net for date formats
$printdate = DateTime::createFromFormat('Ymd', get_post_meta($post->ID, 'event_date', 'true')); //event_date from custom feild
$eventDate = $printdate->format('m/d/Y');
if (time() < strtotime("$eventDate 11:59PM")) { ?>
<!-- the date has not passed SHOW CONTENT -->
<?php } else { ?>
<!-- SORRY the date has passed already-->
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment