mseiwald Posted September 10, 2011 Report Share Posted September 10, 2011 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 Quote Link to comment Share on other sites More sharing options...
tutmeister Posted September 11, 2011 Report Share Posted September 11, 2011 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); ?> Quote Link to comment Share on other sites More sharing options...
mseiwald Posted September 11, 2011 Author Report Share Posted September 11, 2011 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 Quote Link to comment Share on other sites More sharing options...
tutmeister Posted September 11, 2011 Report Share Posted September 11, 2011 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); ?> Quote Link to comment Share on other sites More sharing options...
mseiwald Posted September 11, 2011 Author Report Share Posted September 11, 2011 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 Quote Link to comment Share on other sites More sharing options...
mseiwald Posted September 11, 2011 Author Report Share Posted September 11, 2011 sorry that i didn`t see it before. and a big thank you for your help tutmeister. kind regards Manuel Quote Link to comment Share on other sites More sharing options...
tutmeister Posted September 11, 2011 Report Share Posted September 11, 2011 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); Quote Link to comment Share on other sites More sharing options...
mseiwald Posted September 11, 2011 Author Report Share Posted September 11, 2011 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 Quote Link to comment Share on other sites More sharing options...
tutmeister Posted November 15, 2011 Report Share Posted November 15, 2011 I'm revisiting this issue. Does anyone else have any idea how to achieve this? It's had me stumped for awhile now and I'm close to admitting defeat! Quote Link to comment Share on other sites More sharing options...
mseiwald Posted June 27, 2012 Author Report Share Posted June 27, 2012 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.