How often does this code run? If often, you just might want to generate values for specific days in advance and store them in a database. Even generating them for 100 years in advance costs only 36524 or 36525 rows, which is a pretty trivial amount. Just don't forget to run a cron job on each last day of a century. (Or you could just reuse them, noone will remember the banner ad they saw 100 years ago!)
Aternatively, if it's for something like banner ads, or random images, just keep the location of the ad or image fixed. And replace the image or ad on a daily bases.
Abigail