Rather than looping by day, you can use a single call to mktime().