ARV187
October 22, 2018, 6:00am
1
Hi, I’m trying this function in a table
\<?php echo $flight-\>deptime; ?\>
But my server have NY time and I want UTC time or +6 hours, then I’m trying this:
\<?php echo $flight-\>deptime+'6 hour'; ?\>
But if for example in NY are the 16:38h I get 22 h, not 22:38 h
I tried with +6, with +06:00:00, etc, but nothing.
How I can get deptime in UTC or add 6 hours with minutes?
Thanks!
P.S: This is the source file (I think) to deptime funtion https://github.com/nabeelio/phpvms_v2/blob/master/core/common/ACARSData.class.php
nabeel
October 25, 2018, 2:25pm
2
You’ll have to read it into strformat I think, and then do the parsing out from there
ARV187
October 25, 2018, 5:10pm
3
Im very noob in programation is this? https://www.w3schools.com/php/func_string_sprintf.asp or this? https://www.w3schools.com/php/php_date.asp (Create a Date From a String With PHP strtotime)
Thanks!
P.S: I need modify ACARSData.class.php to get UTC or especific zone time not local (server time) because is more hard and dirty, for example we have deptime, arrtime and lastupdate time in acars table, all in local time (server).
ARV187
October 30, 2018, 1:17am
4
I need this:
\<?php $datetime = '$flight-\>deptime'; $tz\_from = 'America/New\_York'; $tz\_to = 'Europe/Madrid'; $format = 'H:i'; $dt = new DateTime($datetime, new DateTimeZone($tz\_from)); $dt-\>setTimeZone(new DateTimeZone($tz\_to)); echo $dt-\>format($format) . "\n"; ?\>
But with $flight->deptime I get a error, only work with time format (writing the time directly in the code $datetime = ‘15:25’ but the only thing that I have is $flight->deptime.
FIXED :
\<?php $flight-\>deptime; ?\> \<?php $tz\_from = 'America/New\_York'; $tz\_to = 'Europe/Madrid'; $format = 'H:i'; $dt = new DateTime($flight-\>deptime, new DateTimeZone($tz\_from)); ?\> \<?php $dt-\>setTimeZone(new DateTimeZone($tz\_to)); ?\> \<?php echo $dt-\>format($format) . "\n"; ?\>