strtotime only adds 23 hours when passing "+1 day"

strtotime("+1 day") only adds 23 hours after changing server timezone from 'UTC' to 'Europe/Stockholm'. Tried changing php date.timezone to 'Europe/Stockholm'.

  $int_day = strtotime($_POST["start_day"]);
  $str_day = date("Y-m-d H:i:s", $int_day );
  print "today is $int_day<br>\n";
  print "that is, $str_day<br>\n";
  print "going forward..<br>\n";
  $int_day = strtotime("+1 day", $int_day);
  $str_day = date("Y-m-d H:i:s", $int_day);
  print "tomorrow is $int_day<br>\n";
  print "that is, $str_day<br>\n";


  today is 1269039600
  that is, 2010-03-20 00:00:00
  going forward..
  tomorrow is 1269126000
  that is, 2010-03-20 23:00:00

I also tried "+24 hours" instead of "+1 day" STILL only adds 23 hours. :(
Any help is very much appreciated!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mgabAuthor Commented:
Update: After change to summertime (DST, Daylight Savings Time) it only adds 22 hours!

  today is 1270418400
  that is, 2010-04-05 00:00:00
  going forward..
  tomorrow is 1270504800
  that is, 2010-04-05 22:00:00
It seems every thing ok with you code. maybe you have not put actual code here.
but I think following info can help you to understand the issue.

1. there is two hour difference between UTC and StockHolm time

2. date saved in unix timestamp (1270418400 etc..) represent UTC timezone
3. your system timezone settings does not affect timestamp, it is always UTC.
4. while doing conversion between timestamp and date. like  date("Y-m-d H:i:s", $int_day); or strtotime("+1 day", $int_day);
 here make sure that timezone settings are same.
mgabAuthor Commented:
That was the actual code.

After debugging, it seems that date() generates a utc-time but when doing a strtotime("+1 day") it is timezone-aware and only adds the amount of time that would correspond to the current timezone.

I've played a little with gmdate() but with no success, so I just reverted the timezone back for this little script:

      // set default timezone to utc since strtotime() and date() doesn't play along very well

NOTE: This was running PHP 5.2.6-1+lenny8.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.