Jump to content
ARV187

deptime in UTC or +6 hour

Recommended Posts

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 by ARV187

Share this post


Link to post
Share on other sites

You'll have to read it into strformat I think, and then do the parsing out from there

Share this post


Link to post
Share on other sites

@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 by ARV187

Share this post


Link to post
Share on other sites

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 :D:

<?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 by ARV187

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×