How to convert one time zone to anothor time zone

By Hardik Savani | February 17, 2016 | | 604 Viewer | Category : PHP Laravel

Share this post:

Some application required one time zone to convert another time zone.

PHP provide some readymade timezone conversion classes but it a very complecated. so we have try to define this function simple way.

You can createe a simple class and write one function into the class. then you able to use this function everywere.

class convertTimezone


function convert_timezone() // Constructor of the class



function converToTime($conv_fr_zon=0,$conv_fr_time="",$conv_to_zon=0)


//echo $conv_fr_zon;

$cd = strtotime($conv_fr_time);

$gmdate = date('Y-m-d H:i:s', mktime(date('H',$cd)-$conv_fr_zon,date('i',$cd),date('s',$cd),date('m',$cd),date('d',$cd),date('Y',$cd)));

//echo $gmdate";

$gm_timestamp = strtotime($gmdate);

$finaldate = date('Y-m-d H:i:s', mktime(date('H',$gm_timestamp )+$conv_to_zon,date('i',$gm_timestamp ),date('s',$gm_timestamp ),date('m',$gm_timestamp ),date('d',$gm_timestamp ),date('Y',$gm_timestamp )));

return $finaldate;



Example For Use

$c = new convertTimezone();

$resultTime = $c->converToTime(5.30, “2011-05-09 11:00:00”, -13);

$resultTime = $c->converToTime(-4, “2011-05-09 11:00:00”, 10);

The first one converts 5th May, 2011, 11 am from the timezone GMT+0530hrs to GMT-1300hrs

The second one coverts 5th May,2011 11 am from the timezone GMT-0400hrs to GMT1000 hrs