Jump to content

deptime in UTC or +6 hour


ARV187

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
Link to comment
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
Link to comment
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
Link to comment
Share on other sites

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...