Category Archives: php

php date

 

<?php if ( strtotime(get_the_date()) == strtotime(date(“F j, Y”)) ) { echo ‘true’; } else { echo ‘false’; } ?>

<?php //echo date(“j.m.Y”); ?>);
<?php //echo get_the_date(); ?>);
<?php echo date(“F j, Y”,strtotime(‘-3 day’)); ?>);

get_the_date(“F j, Y”,strtotime(‘-2 day’));

Group posts by date in WordPress

$args = array('posts_per_page' => -1, 'orderby' => 'date' );
$myQuery = new WP_Query($args);
$date = '';

if ( $myQuery->have_posts() ) : while ( $myQuery->have_posts() ) : $myQuery->the_post();

if ( $date != get_the_date() ) {
    echo $date;
    echo '<hr />';
    $date = get_the_date();
}

the_title(); // or whatever you want here.
echo '<br />';

endwhile; endif;
wp_reset_postdata();

More info on the query here: http://codex.wordpress.org/Class_Reference/WP_Query