Reputation: 3
I need help to display a simple message when one of my seminars ends. I have something like "This seminar has ended" in mind, but can't figure out the right formats. I'm using wordpress and the Advanced Custom Fields (ACF) plugin for custom fields:
Code:
<?php
$today = date('Ymd');
$sem_date = get_field('sem_date'); // Output format d / m / y (has to be this format on the site)
if($today > $sem_date){ ?>
<div class="oops">
This seminar has ended!
</div>
<?php } ?>
Upvotes: 0
Views: 1552
Reputation: 4055
Get today's date as a Date Object:
$today = new DateTime( 'today', new DateTimeZone('America/Chicago') );
Get seminar's date as a Date Object:
$sem_date = new DateTime( get_field('sem_date') );
Now you can compare the two Date objects:
$today > $sem_date
Upvotes: 1