Find today's flight - FlightInfoEx

Hi,

I’m trying to build a Slackbot for our travelling colleagues and FlightInfoEx is giving me some strange results back (or I’m interpreting wrong).


$flightInfoEx = Invoke-RestMethod -Method Get -Uri "https://flightxml.flightaware.com/json/FlightXML2/FlightInfoEx?ident=QFA400&howMany=4" -Headers $Headers -Verbose

Function ConvertFrom-Unixdate ($UnixDate) {
  [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($UnixDate))
}
Function Get-LocalTime($UTCTime)
{
  $strCurrentTimeZone = 'AUS Eastern Standard Time'
  $TZ = [System.TimeZoneInfo]::FindSystemTimeZoneById($strCurrentTimeZone)
  $LocalTime = [System.TimeZoneInfo]::ConvertTimeFromUtc($UTCTime, $TZ)
  Return $LocalTime
}

Get-LocalTime -UTCTime (ConvertFrom-Unixdate $flightInfoEx.FlightInfoExResult.flights[0].filed_departuretime).toString()
Get-LocalTime -UTCTime (ConvertFrom-Unixdate $flightInfoEx.FlightInfoExResult.flights[1].filed_departuretime).toString()
Get-LocalTime -UTCTime (ConvertFrom-Unixdate $flightInfoEx.FlightInfoExResult.flights[2].filed_departuretime).toString()
Get-LocalTime -UTCTime (ConvertFrom-Unixdate $flightInfoEx.FlightInfoExResult.flights[3].filed_departuretime).toString()
VERBOSE: GET https://flightxml.flightaware.com/json/FlightXML2/FlightInfoEx?ident=QFA400&howMa
ny=4 with 0-byte payload
VERBOSE: received 2206-byte response of content type application/json; charset=UTF-8

Sunday, 9 October 2016 5:00:00 PM
Friday, 9 September 2016 4:00:00 PM
Tuesday, 9 August 2016 4:00:00 PM
Saturday, 9 July 2016 4:00:00 PM

QFA400 flies Melbourne to Sydney, every day at 6am local time. Why am I not getting tomorrow’s and the flight from today, yesterday and the day before with that query above?

How do I find today’s or actually the next flight with that ID?

Cheers
David

I am now going this way. I only get the Flightnumber from the user.

AirlineFlightSchedules
GetFlightId (using the departure time from AirlineFlightSchedules)
FlightInfoEx