Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中显示GMT偏移量_Php_Mysql_Time_Gmt - Fatal编程技术网

在PHP中显示GMT偏移量

在PHP中显示GMT偏移量,php,mysql,time,gmt,Php,Mysql,Time,Gmt,我有一个时区数据库 查询的每个时区行都有一个Time_start字段和另一个称为gmt_offset的字段 例如,一行是 [zone_id] => 191 [zone_name] => Asia/Kolkata [country_name] => India [time_start] => -891582800 [gmt_offset] => 23400 [dst] =&

我有一个时区数据库

查询的每个时区行都有一个Time_start字段和另一个称为gmt_offset的字段

例如,一行是

        [zone_id] => 191
        [zone_name] => Asia/Kolkata
        [country_name] => India
        [time_start] => -891582800
        [gmt_offset] => 23400
        [dst] => 0
我需要从这里显示的是国家和GMT偏移量,就像通过PHP显示的一样

India: GMT +5:30
我试过了

            $plusoffset = $row->time_start+$row->gmt_offset;
            $minusoffset = $row->time_start-$row->gmt_offset;
            echo "Time Start: ". date('h:i:s',$row->time_start).'<br>';
            echo "Offset: ". date('h:i:s',$row->gmt_offset).'<br>';
            echo "Start+Offset: ". date('h:i:s',$plusoffset).'<br>';
            echo "Start-Offset: ". date('h:i:s',$minusoffset).'<br>';
$plusoffset=$row->time\u start+$row->gmt\u offset;
$minusoffset=$row->time\U start-$row->gmt\U offset;
回显“时间开始:”。日期('h:i:s',$row->time_start');
回声“偏移:”。日期('h:i:s',$row->gmt\U偏移量)。';
回显“开始+偏移:”。日期('h:i:s',$plusoffset)。';
回显“开始偏移:”。日期('h:i:s',$minusoffset)。';
但这些都没有显示正确的偏移量


我肯定我错过了一些显而易见的东西,但我一辈子都想不出来。

只要把你到达那里的秒数(23400)转换成小时和分钟

$gmt_offset = 23400;

$hours = (int)($gmt_offset / 3600);
$minutes = $gmt_offset % 3600 / 60;
echo 'Offset: ' . $hours . ':' . $minutes;

它仍然显示一个小时的额外时间。它显示的不是5:30,而是6:30。23400肯定是6.5小时(你可以除以3600看你自己),你应该问为什么是23400。