Jump to content

Recommended Posts

Posted

Hi,

Is there a way to show not only the remaining flighttime but also the estimated arrival time based on GMT + timeremaining or something like this?

Sorry for that stupid question but I`m clueless in writing codes.

kind regards

manuel

Posted

Untested, but I believe the following will work:

//Displays time remaining

<%=flight.timeremaining%>

//displays: 17:59 UTC
<?php 

$remaining = '<%=flight.timeremaining%>'; 

$time = strtotime("$remaining"); 

print gmdate('H:i T', $time);

?>

Posted

hi,

thank you for your help.

I have just tried it but it always shows 00:00 GMT. the time remaining shows correctly but ETA is always 00:00 GMT.

any ideas?

kind regards

Manuel

Posted

Yeah, sorry yesterday was a long day. I have a working code below, but it doesn't work in phpVMS as the only way I know of getting the remaining time is to use the API call <%=flight.timeremaining%>, which won't parse within PHP code (or at least not to my knowledge). So I haven't answered your question, but you might be able to work on it using this (you can manipulate the time by changing the hours with strftime:



<?php

$time = strtotime("now +07 hours");

print gmdate('H:i T', $time);

?>

Posted

hi no problem thank you very much.

i have tested it with a short test flight and it shows correctly if i replace the api call with +15 or anything else but as soon as i use the api call it gives 00:00GMT again.

kind regards

Manuel

Posted

You're welcome. Do you have it working yet? I've been working on it myself, but my lack of knowledge surrounding the way phpVMS works is showing.

This is my current code, just FYI. It's not working, but it explodes the HH:MM, allowing you to add the hours and minutes to the API call in theory. What I really need to know is why the API call won't work. I can echo it in single quotes, so it should work if I replace 12:00 with it, but it doesn't--very frustrating.


$returnedString = '12:00';
$returnedTime = explode(':', $returnedString);

//$time = strtotime("now +{$returnedTime[0]} hours, +{$returnedTime[1]} minutes");
// Or this
$time = strtotime('now +' . $returnedTime[0] . ' hours, +' . $returnedTime[1] . ' minutes');

print gmdate('H:i T', $time);

Posted

no i havent got it working...I also searched everywhere and tried some things but it`s always the same 00:00 or nothing at all :( for now i`ve set it back to time remaining on the site.

i would have loved to get this working and show the ETA on my site but it`s almost impossible for me to find out why it doesn`t as i never ever coded anything before ;)

kind regards

Manuel

  • 2 months later...
  • 7 months later...
Posted

Hi Paul,

i just found this old topic and tried again to get this to work and surprisingly the code you have posted above now works perfectly on my site..... don`t ask me why.

I have this:

<?php
$returnedString = $flight->timeremaining;
$returnedTime = explode(':', $returnedString);
$time = strtotime('now +' . $returnedTime[0] . ' hours, +' . $returnedTime[1] . ' minutes' );
print gmdate('H:i T', $time);
?>  

and it works great ;)

so thank you again for that

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...