PHP Code To Convert DateTime To Your Prefer Timezone
This function can convert DateTime to your prefer timezone. Here the code:
function convertTimezone($date,$zone){
$dates = explode(" ", $date);
$tgl = explode("-",$dates[0]);
$time = explode(":",$dates[1]);
$newtime = mktime($time[0]+$zone,$time[1],$time[2],$tgl[1],$tgl[2],$tgl[0]); // H,i,s,m,d,Y
$newdate = date('Y-m-d H:i:s',$newtime);
return $newdate;
}
$date = "2014-03-30 06:01:09";
$newDate = convertTimezone($date,"+7");
echo $newDate;
Good Luck !!!
$dates = explode(" ", $date);
$tgl = explode("-",$dates[0]);
$time = explode(":",$dates[1]);
$newtime = mktime($time[0]+$zone,$time[1],$time[2],$tgl[1],$tgl[2],$tgl[0]); // H,i,s,m,d,Y
$newdate = date('Y-m-d H:i:s',$newtime);
return $newdate;
}
$date = "2014-03-30 06:01:09";
$newDate = convertTimezone($date,"+7");
echo $newDate;
0 comments:
Post a Comment