hasanatkazmi Posted August 8, 2007 Share Posted August 8, 2007 I am new to PHP, previously I used to code in C++ I am trying to convert time from server to GMT, $s=localtime(); $h=$s[2]; $m=$s[1]; $s=$s[0]; if ($h<10)$h="0".$h; if ($m<10)$m="0".$m; if ($s<10)$s="0".$s; $gmtdiff=(int)date('O'); $time=(int)$time; $timegmt=$time+$gmtdiff; $timegmt=$timegmt.$s; but $timegmt comes out to as 0000ss, help plz Link to comment https://forums.phpfreaks.com/topic/63876-solved-simple-addition-problem/ Share on other sites More sharing options...
DJTim666 Posted August 8, 2007 Share Posted August 8, 2007 <?php $s=localtime(); $h=$s[2]; $m=$s[1]; $s=$s[0]; if ($h<10)$h="0".$h; if ($m<10)$m="0".$m; if ($s<10)$s="0".$s; $gmtdiff=(int)date('O'); $time=(int)$time; $timegmt=$time+$gmtdiff; $timegmt.=$timegmt.$s; ?> Try that code. -- DJ Link to comment https://forums.phpfreaks.com/topic/63876-solved-simple-addition-problem/#findComment-318375 Share on other sites More sharing options...
hasanatkazmi Posted August 8, 2007 Author Share Posted August 8, 2007 oops this . didnt help Link to comment https://forums.phpfreaks.com/topic/63876-solved-simple-addition-problem/#findComment-318380 Share on other sites More sharing options...
hasanatkazmi Posted August 8, 2007 Author Share Posted August 8, 2007 here is the solution $s=localtime(); $h=$s[2]; $m=$s[1]; $s=$s[0]; if ($h<10)$h="0".$h; if ($m<10)$m="0".$m; if ($s<10)$s="0".$s; $localtime=$h.$m; $gmtdiff=date('O'); $gmttime=$localtime-$gmtdiff; $gmttime.=$s; Link to comment https://forums.phpfreaks.com/topic/63876-solved-simple-addition-problem/#findComment-318392 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.