Q:

PHP calculations with time() and DST issue

I'm using a script that insert a date (yyyy-mm-dd) which is X days later than the current date. I add X seconds on the first timestamp to get the second one, at 12:00AM.
Server timezone is UTC -5 and I also set it in my scripts with
date_default_timezone_set('America/Montreal');

We'll set clocks one hour back on NOVEMBER 6 and any mathematical calculations with time() seem affected.
(When Daylight Saving Time ends in the fall, clocks are set back an hour and Standard Time resumes.)
At 2:00AM, it'll be 1:00AM on Nov. 6

For exemple, the timestamp of date 1: 1320379200 (Friday 4th November 2011 12:00:00 AM, BEFORE time change)
I want to add 7 days to this date... 1320379200 + (7 * 24 * 60 * 60)  
Timestamp of the new date is now 1320984000 (Thursday 10th November 2011 11:00:00 PM, AFTER time change)
but it should be 1320987600 (Friday 11th November 2011 12:00:00 AM)
I miss 3600 seconds, so one hour. 

So just to make it clear (pseudo-code):  
$timestampOfStartingDate = 1320379200   
echo timestampToDate($timestampOfStartingDate) // show 2011-11-04 (Friday 4th November 2011 12:00:00 AM)

$newTimestampAfter7days = $timestampOfStartingDate + (7 * 24 * 60 * 60)  
echo timestampToDate($newTimestampAfter7days)  // show 2011-11-10 instead of 2011-11-11 (Thursday 10th November 2011 11:00:00 PM instead of Friday 11th November 2011 12:00:00 AM)

So I'm missing one hour, which is really probably related to the daylight saving time.

The thing is I don't know how to fix that. I don't want to re-do it when we'll re-enter in daylight saving time.
I hope you guys understand what I'm saying, as I'm a little confused.
Also please excuse my english, I'm doing my best!

A:

You should be adding 7 days, not x number of seconds.
strtotime("+7 days", $timestampOfStartinDate);

Alternatively, use PHP's DateTime class.

