Generating fortnights using time()

    Date: 02/08/05 (PHP Community)    Keywords: database, web

    OK, I'm trying to write a script that tells you when your next recycling collection is (don't laugh). In my city, your recycling is collected on a certain day (the actual day depends where exactly you live) every two weeks.

    What I'd like to do is have a web page with a list of street names and the date of your next collection, which is generated based on the current date (using time() ). I'm running into a bit of trouble generating the next collection day because it's once a fortnight and I can't just (for example) increment the current time() until I get to the right day because it could be more than a week away.

    At the moment I've got all the street names in a database with a timestamp of a known collection. Then I just increment the "known collection" timestamp by two weeks until the value exceeds time().

    What I'd like to know is - is there an easier way to do this? I figure once the script has been up and running for a while it's a bit silly to start at a date that was years ago and increment it until it passes the current date.

    UPDATE: Sorted it (maybe). I don't have server access to set up a cron job, but I can kind of achieve the same effect by querying and updating the database in the script before outputting the values. Cheers! :) You can see the script in action here (woooo).

    Source: http://www.livejournal.com/community/php/256785.html

« ftp || stripping HTML formatting »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home