1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?php function converttimezone($fromtime, $fromtimezone, $totimezone) { $from = new DateTimeZone($fromtimezone); $to = new DateTimeZone($totimezone); $originaltime = new DateTime($fromtime, $from); $totime = new DateTime($originaltime->format("c")); $totime->setTimezone($to); return $totime; } $display_converted_time = converttimezone("2014-05-27 15:01:00", "Asia/Calcutta", "America/Louisville"); echo $display_converted_time->format("Y-m-d H:i:s"); echo "\n"; ?> |