Found this answer...
<?php function is_am_pm($str){ if(strpos($str, "am") !== false || strpos($str, "AM") !== false) return "am"; if(strpos($str, "pm") !== false || strpos($str, "PM") !== false) return "pm"; } function get_only_int($str){ return (int) preg_replace('/\D/', '', $str); } function gmt_to_gmt($str,$from_gmt,$to_gmt = "GMT +10"){ if(!is_numeric($from_gmt)) $from_gmt = get_only_int($from_gmt); if(!is_numeric($to_gmt)) $to_gmt = get_only_int($to_gmt); $temp_time = explode("-",$str); $begin_time_s = is_am_pm($temp_time[0]); $begin_time = get_only_int(trim($temp_time[0])); $end_time_s = is_am_pm($temp_time[1]); $end_time = get_only_int(trim($temp_time[1])); $time_diff = $to_gmt - $from_gmt; $begin_time = $begin_time + $time_diff; $end_time = $end_time + $time_diff; if($begin_time > 13){ if($begin_time_s == "am"){ $begin_time -= 12; $begin_time .= "pm"; }else{ $begin_time -= 12; $begin_time .= "am"; } }else{ $begin_time .= $begin_time_s; } if($end_time > 13){ if($end_time_s == "am"){ $end_time -= 12; $end_time .= "pm"; }else{ $end_time -= 12; $end_time .= "am"; } }else{ $end_time .= $end_time_s; } return $begin_time . " - " . $end_time; } echo gmt_to_gmt("7am - 11pm", "GMT +0" , "GMT +2"); ?>
but its not displaying some parts correctly. when 7am - 11pm is given it should return 9am - 1pm but here its outputting 9am - 13pm