WordPress.org

Ready to get started?Download WordPress

Forums

Simple Fields
Compare custom date (1 post)

  1. hkieze
    Member
    Posted 1 year ago #

    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>'; }}
    ?>

    http://wordpress.org/extend/plugins/simple-fields/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags