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).

tla starter kit

Related posts:

  1. Optimizing WordPress Page Titles, Post Titles and Page Slugs While wordpress is one of my favorite CMS platforms, out...
  2. Creating the Ultimate Digg Post Recently I got to thinking, what would it take to...
  3. Thesis Tutorial – Custom Post Dates The following post is part of my Thesis tutorial series....
  4. How Do You Archive Pages on a High Post Volume Website Today’s post is an answer to a question I took...
  5. What is a Compilation Post I came across a post today that was actually pretty...

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. Ezilon.com Regional Directory - Check to see if your website is listed!
  4. Need an SEO Audit for your website, look at my SEO Consulting Services
  5. Directory Journal - Get permanent deep links in a search engine friendly directory
  6. TigerTech - Great Web Hosting service at a great price.
  7. Article-Writing-services.org - Article Writing Services creates quality content for websites and blogs at no cost to site owners.
  8. Link Building Services - Hire WeBuildLink.com for well-planned advanced link building campaigns. Very affordable. Contact us now for a FREE evaluation.
  9. Try HOTH Plus+ NOW - The First 1-Stop Link Building Solution Powered by 100% College Educated Copywriters!
  10. Professional website designs - Get a unique brand image with website designs that sets you apart and convert your visitors into customers. Make a brand, not just a website

See my disclaimer about advertising and affiliate links