Compare custom date
-
How can i compare a custom date with the current date.
What do i want?
I only want to show posts that are in the future (from custom date). The code below shows all posts. Could anyone help me?<?php
$args = array( ‘numberposts’ => ‘5’, ‘category’ =>’1′, ‘orderby’ => ‘datum’, ‘order’ => ‘asc’);
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
$date = DateTime::createFromFormat(‘Ymd’, get_field(‘datum’, $recent[“ID”]));
$today = date(‘Y-m-d’, $timestamp);
if ($date > $today){
echo ‘<div id=”containergame”>’;
echo $date->format(‘M’);
echo ‘
‘;
echo $date->format(‘d’);
echo ‘</div>’; }}
?>
The topic ‘Compare custom date’ is closed to new replies.