I want an iterator that will generate:
January 1, 1970,
January 2, 1970,
and so on…
In Oracle’s SQL, you can iterate over a range of days using the NEXT_DAY() or apply arithmetic operators to dates. Are there any similar functions in PHP?
You may think that since a day has 86400 seconds, that you can just use the multiples of 86400. There are a few problems with this approach but the killer is that leap seconds are necessary to keep UNIX time in synchronization with the Earth’s rotation. Don’t believe me? See http://en.wikipedia.org/w/index.php?tit ... ntable=yes. Therefore, there are lots of days, like March 5, 2007, whose UNIX time is not a multiple of 86400.
I want a set of functions where I don’t need to worry about leap years with February 29. If I have a date that says “February 28” for some year, I can just ask the iterator for the next date, and it will figure out if there is a leap year to worry about.
Any suggestions?
Thanks.
How to iterate over days?
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Code: Select all
$tomorrow = strtotime('February 28, 2007 +1 day');