Timestamp issues


#1

Timestamps on some of my queries are from two days in the future.

Ex. I ran a query on [flight]UAL202[/flight]

I Got this


Flight CallSign: UAL202
stdClass Object
(
    [faFlightID] => UAL202-1402982182-airline-0012
    [ident] => UAL202
    [aircrafttype] => A320
    [filed_ete] => 05:13:00
    [filed_time] => 1402982182
    [filed_departuretime] => 1403181900
    [filed_airspeed_kts] => 409
    [filed_airspeed_mach] => 
    [filed_altitude] => 0
    [route] => 
    [actualdeparturetime] => 0
    [estimatedarrivaltime] => 1403201280
    [actualarrivaltime] => 0
    [diverted] => 
    [origin] => KLAX
    [destination] => KEWR
    [originName] => Los Angeles Intl
    [originCity] => Los Angeles, CA
    [destinationName] => Newark Liberty Intl
    [destinationCity] => Newark, NJ
)
1403201280 - 1403028816
UAL202 should arrive in 48 hours and 54 minutes.


Source:



<?php

$options = array(
	'trace' => true,
	'exceptions' => 0,
	'login' => 'ethansattler',
	'password' => '---------------------------------------'
);
$client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2/wsdl', $options);

echo "Flight CallSign: ";
$line = fgets(STDIN);
$line = trim($line, "
");

$params = array(
	"ident" => trim(strtoupper($line)),
	"howMany" => 1,
	"offset" => 0
);

$result = $client->FlightInfoEx($params);
$flight = $result->FlightInfoExResult->flights;
print_r($flight);

if ($flight->actualarrivaltime != 0) {
	echo "You should be arriving momentarily.
";
} else {
	date_default_timezone_set("UTC");
	$tm = (($flight->estimatedarrivaltime - time()) / 60) / 60;
	echo $flight->estimatedarrivaltime . " - " . time() . "
";
	echo $line . " should arrive in " . round($tm) . " hours and " . round(($tm - floor($tm)) * 60) . " minutes.
";
}



#2

Do not specify howMany=1 to FlightInfoEx. That will almost never return the flight you are actually interested in.

FlightInfoEx returns multiple flights for the ident that you specify, in chronological order starting with the furthest in the future and going backwards. You need to allow multiple results to be returned and evaluate the results to pick which flight your app is actually interested in.