I live in Denmark - but am setting up a page for a friend in USA (Washington State). The page is hosted at Surftown, in Denmark.
I know there is a 9 hour difference, so I set:
date_default_timezone_set('America/Los_Angeles');
But there is something I obviously don't quite understand about time zones / date()
and strtotime()
because:
Via text input I am trying to save a specific date and time to the database.
Lets say that $_POST[date]
input is: '01/29/2015' and $_POST[time]
input is: '02:00 PM'.
I then create a stamp using:
strtotime($_POST[date].' '.$_POST[time]);
But when I try to output this, I get the correct date - but 9 hours is added to time? Why is this?
I guess I could just remove the time zone setting for this specific task - but I'd like to understand why. I am setting the time zone because I also need to save some timestamps based on the actual time of the user (in Washington state - not Denmark).
Can you help?