WordPress, How Many Days Old is the Post

Over on Performancing.com Andy, says the money is in the archives, stupid. Nick talks about Monetizing your Blog, by showing different levels of advertising based on how old post is and whether someone is logged in or not. Now Andy’s doing a blog monetization makeover, and time sensitive ads came up again. Since I’ve got the hood open on this WordPress install I figured I would work up some code to figure out how old a post is.


$postdate = str_replace("-", " ",substr($post->post_date, 0,10));
$postd = explode(" ", $postdate);
$ageunix = (( time() - mktime('','','', $postd[1], $postd[2], $postd[0])));
$days_old = floor($ageunix/(24*60*60));

Basically what I’m doing is getting time and date of the post. I then isolate the just date and remove out “-” characters. I explode it into an array, convert them to unixtime, and do the subtraction. Then convert it back from UNIX time to days old expressed as an integer value (my high school math teacher Sister Miriam would be proud).

GraywolfSEO.com runs on the Genesis Framework

Genesis Framework

Genesis lets you to quickly and easily build amazing websites with WordPress. Whether you're a novice or advanced developer, Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.
It's that simple - start using Genesis now!


Take advantage of the 6 default layout options, comprehensive SEO settings, rock-solid security, flexible theme options, cool custom widgets, custom design hooks, and a huge selection of child themes ("skins") that make your site look the way you want it to. With automatic theme updates and world-class support included, Genesis is the smart choice for your WordPress website or blog.


tla starter kit

Advertisers:

  1. Text Link Ads - New customers can get $100 in free text links.
  2. BOTW.org - Get a premier listing in the internet's oldest directory.
  3. Need an SEO Audit for your website, look at my SEO Consulting Services
  4. TigerTech - Great Web Hosting service at a great price.
More in npb, npp, ntt, Programming
Six Degrees of a Lesbian Porn Scraper

Perhaps you've heard of the play or seen the movie Six Degrees of Separation. One of the elements of the...

SEO Case Study: Outbound Links

SEO Case Study: Outbound Links Experiment: To determine if outbound links help a page rank for a term hypothesis: By...

Creative Link Building Ideas

There's lots of talk on the net right now that reciprocal linking is dead, which I disagree with. I will...

Close