note
physgreg
I think the cause of your problem is trying to calculate the date at midnight, which will get confused by daylight saving time. PHP has the same problem. I got round it by using 12 noon as my base time.
<p><b>Update:</b> I tested this, and it works if you simply substitute 12 for 0 in every hour field.
205964
205964