• When I run this code it shows the date of 1970-01-01 for $postdate
    I want to be able to compare the date the post was created vs other dates. If I use the_date() it echos the date everytime, and I don’t want echos. Any help is appreciated.

    if (is_single())
    	{
    		$postdate = date('Y-m-d',strtotime($post->post_date));
    		if ($postdate < date('Y-m-d', strtotime("-7 days")))
    		{
    			 //return something
    		}
    	}

Viewing 1 replies (of 1 total)
  • Test for posts that are so many days old date (in this case 46 days)

    <?php
    $mylimit=46 * 86400; //days * seconds per day
    //$post_age = date('U') - get_post_time('U');
    $post_age = date('U') - mysql2date('U', $post->post_date_gmt); //or use $post->post_date
    if ($post_age < $mylimit) {
    echo 'this post is within my date limit ';
    }
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘what wrong with this small code? (using the_post)’ is closed to new replies.