Php GMT时间格式转换为整数格式

Php GMT时间格式转换为整数格式,php,javascript,Php,Javascript,我试图显示不同时区的时钟。当我浏览网页时,它看起来像是用javascript中的数字表示偏移量(例如+5.5小时)。但是我们获取gmtformat的方式是php中的+05:30,我正在尝试将其输入到javascript函数中。有什么函数可以用来转换吗 /*CLOCK CODE IN JAVASCRIPT*/ function startclock(field, timediff, newOrRepeat) { var clockAction=newOrRepeat; if (timed

我试图显示不同时区的时钟。当我浏览网页时,它看起来像是用javascript中的数字表示偏移量(例如+5.5小时)。但是我们获取gmtformat的方式是php中的+05:30,我正在尝试将其输入到javascript函数中。有什么函数可以用来转换吗

/*CLOCK CODE IN JAVASCRIPT*/
function startclock(field, timediff, newOrRepeat)
{ 
    var clockAction=newOrRepeat;
if (timediff=="") {$(field).html("-------");return false;}
    /****THERE ARE MORE STUFF IN BETWEEN AND AFTER WHICH IS NOT RELEVANT TO OFFSET****/
var secondsDiff=0;
var secondsTimeZone = 0;
//calculate the difference in time set by both the timezone as well as the DST
secondsTimeZone = parseInt(timediff);


if ($("input[name='daylight']:checked").val()=="on" && $(field).siblings("#isDaylight").val()=="no")
    secondsDiff=secondsTimeZone + 3600;
else if ($("input[name='daylight']:checked").val()=="off" && $(field).siblings("#isDaylight").val()=="yes")
    secondsDiff=secondsTimeZone - 3600;
else 
    secondsDiff = secondsTimeZone;

var thetime=new Date();

thetime.setUTCSeconds(parseInt(thetime.getUTCSeconds())+parseInt(secondsDiff));
var nhours=thetime.getUTCHours();
var nmins=thetime.getUTCMinutes();
var nsecn=thetime.getUTCSeconds();

}

我直接从php获取gmt格式,并将其传递给此函数。

Whathaveyoutried?把什么转换成什么。给出示例和代码。我正在尝试将+05:30转换为5.5。您必须在“:”之后提取整数值,如果它不是零,则将其除以60。然后将结果放在“:“Whathaveyoutried?”?把什么转换成什么。给出示例和代码。我正在尝试将+05:30转换为5.5。您必须在“:”之后提取整数值,如果它不是零,则将其除以60。然后将结果放在“:”之后,我明白了,但我正在寻找内置的php函数或javascript函数。尽管如此,它还是有效的。谢谢,我知道了,但我正在寻找一个内置的php函数或javascript函数。尽管如此,它还是有效的。非常感谢。
function convert_time($time){
    $parts = explode(':', $time);
    return $parts[0] + number_format($parts[1]/60, 2);
}