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'.

<code>
  $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";
</code>

Outputs:

  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!
mgabAsked:
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
0
nasirbestCommented:
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
http://www.timeanddate.com/worldclock/custom.html?continent=europe

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.
0
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:

<code>
      // set default timezone to utc since strtotime() and date() doesn't play along very well
      date_default_timezone_set("UTC");
</code>

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

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
PHP

From novice to tech pro — start learning today.