jansky and mikawhat, be cuatious about the use of the strtotime and strtftime functions. They will not work with dates prior to January 1, 1970 on Windows and certain other OS's (See Note Below). Follow planetsim's suggestion to search these forums, and once you find some scripts, post back for help implementing them. (Also, how are you storing the date in your DB? It makes a difference in how you'd prepare to do the actual calculations.)
From the PHP Manual for strtotime
Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems.