Jump to content

time zone converting


astralaaron
 Share

Recommended Posts

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 by astralaaron
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...