ARV187 Posted October 22, 2018 Report Share Posted October 22, 2018 (edited) 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 22h, not 22:38h 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 Edited October 23, 2018 by ARV187 Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted October 25, 2018 Administrators Report Share Posted October 25, 2018 You'll have to read it into strformat I think, and then do the parsing out from there Quote Link to comment Share on other sites More sharing options...
ARV187 Posted October 25, 2018 Author Report Share Posted October 25, 2018 (edited) @Nabeel 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). Edited October 29, 2018 by ARV187 Quote Link to comment Share on other sites More sharing options...
ARV187 Posted October 30, 2018 Author Report Share Posted October 30, 2018 (edited) 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"; ?> Edited October 30, 2018 by ARV187 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.