I'm wondering if anyone could post the PHP code I would need to do the following logic:
If current date is less or equal to August 01 2010 + 120 days, then post this HTML code, else post nothing.
I'm looking to setup an automatic link expiry thingy.
I'm wondering if anyone could post the PHP code I would need to do the following logic:
If current date is less or equal to August 01 2010 + 120 days, then post this HTML code, else post nothing.
I'm looking to setup an automatic link expiry thingy.
Sorry if this isn't helpful but it was the fastest thing I could put together (I'm a little rusty).
I wrote a quick function that you can put anywhere you like on the page / site / whatever and whenever you call that function, it will automatically check the html you enter for whatever parameters you set.
Here's the function:
And to call the function, just paste this code where your html should go:PHP Code:<?php
function check_expiration ($month, $day, $year, $purchasedays, $html) {
$today = time();
$date = mktime(0,0,0,$month,$day,$year);
$purchasetime = "+" . $purchasedays . " days";
$expire = strtotime($purchasetime,$date);
if ($today < $expire) {
echo $html;
}
}
?>
The first three numbers would be the purchase date (or start date) of the link in the format month,day,year.PHP Code:<?php check_expiration(8,1,2010,120,'HTML GOES HERE'); ?>
The fourth number is the number of days to display the html
And the fifth spot is where the actual html goes
Like I said, I'm not sure if this is helpful or not, but it was the best way I could come up with doing it without having to repeat all kinds of code over and over and over again.
Thanks Mike, that sounds like it's exactly what I wanted. I'll play around with it this weekend. I'm sure others would be interested in this too.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks