Domanda

New-York: GMT - 5
Chicago: GMT - 6

Time of departure: 07:00 (New-York time); travel time: 02:48.

How do I know at what time I'll be in Chicago? (Chicago time)

I'm sorry that I could not give its decision. Thanks.

È stato utile?

Soluzione

You would use a combination of DateTime(), DateInterval(), and DateTimeZone():

$flight = new DateTime('07:00', new DateTimeZone('America/New_York'));
$flight->add(new DateInterval('PT2H48M'));
$flight->setTimeZone(new DateTimeZone('America/Chicago'));
echo $flight->format('h:iA');
  1. Create a DateTime() object representing the departure time in New York's timezone
  2. Add 2 hours and 48 minutes of flight time
  3. Change the timezone to Chicago's timezone
  4. Print out the arrival time

Demo

Altri suggerimenti

Time of Arrival (chicago TIme) = Time of departure(New-York time) + travel time: 02:48 + (New-York: GMT + Chicago: GMT)(in hours)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top