While updating the genpets.com site I decided I wanted to add a forum, of course, not a real one as I don't have enough free time to police it. So I needed to create and code something that would look real, which means it would have to update all by itself.
The first trick to that was date control, if all the dates are set for this week, that's not going to do me much good a year from now is it?
I started out writing some longer if statments but then as I read more about the date commands in PHP I realized it could subtract the dates (or add) all on it's own, without having to be told HOW. (IE september 3rd minus 5 days, we'd have to tell the system to update the month to august)
Here's a little snippet of code I used, it works great, so feel free to cut and paste.
// this simple code controls how the dates work on the page. it subtracts days to make it appear the site is always being updated.
//it is also 'smart' so if it subtracts say 5 days from october 2, it will make it september... cool eh?
$date = date('m/d/Y', strtotime("-0 days"));
$date3 = date('m/d/Y', strtotime("-3 days"));
$date10 = date('m/d/Y', strtotime("-10 days"));
$date1 = date('m/d/Y', strtotime("-1 days"));
you don't have to subtract days either, you could subtract a month or year, or whatever suits your fancy, yes it will compensate for leap year etc...
(126) Total entries in journal
// Finland 2003
"That was when I realized. I asked myself could some of what these people be talking about actually be dangerous? And the best thing I can do is stay close to them, track what they are interested in and either hack it or try to confuse the spaces in which they operate". - Rob Van Kranenburg