astralaaron Posted February 5, 2014 Share Posted February 5, 2014 (edited) I have been up all night trying to figure this out, please point out what I am doing wrong! $laTimezone = new DateTimeZone('America/Los_Angeles');$nyTimezone = new DateTimeZone('America/New_York'); // viewer is in NY and should see what time in NY it will be when it is 4:40 in LA.$laDateTime = new DateTime('2014-02-05 16:40', $laTimezone); //user scheduled for 4:40 Feb 5th (LA TIME ZONE)$offset = $nyTimezone->getOffset($laDateTime);$nyDateTime = date('Y-m-d H:i', $laDateTime->format('U') + $offset);echo $laDateTime->format('Y-m-d H:i') . ' in (LA) is ' . $nyDateTime . ' in (NY) '; Basically, someone posts a "meeting" time in Los Angeles at 2014-02-05 16:40. Someone in New York browsing the posts sees the meeting from Los Angeles, but instead of 2014-02-05 16:40, they see 2014-02-05 19:40 because that is what time it will be in NY when it is 16:40 in LA. I can't seem to get it working the way I want it. EDIT: here is the output: 2014-02-05 16:40 in (LA) is 2014-02-05 12:40 in (NY) Edited February 5, 2014 by astralaaron Link to comment Share on other sites More sharing options...
justsomeguy Posted February 5, 2014 Share Posted February 5, 2014 Why not create another DateTime object and set it to the same Unix timestamp, but set it to the other timezone? Link to comment Share on other sites More sharing options...
astralaaron Posted February 6, 2014 Author Share Posted February 6, 2014 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now