How to convert given time in NY zone into UTC zone by php. I will give only the time not date ( ex. 12:30 am ). I wants to convert the given time into UTC time like ( 05:30 am ).
Asked
Active
Viewed 1,453 times
2
-
http://stackoverflow.com/questions/2505681/timezone-conversion-in-php – Amit Rajput Dec 21 '15 at 05:34
-
3http://stackoverflow.com/questions/3905193/convert-time-and-date-from-one-time-zone-to-another-in-php – Amit Rajput Dec 21 '15 at 05:34
-
@AmitRajput in the example they converted by using both date and time, but in my query i have used only time – Gugan Abu Dec 21 '15 at 05:35
2 Answers
2
As Coordinated Universal Time (UTC) is 5 hours ahead of New York (NY), NY, USA. So you just need to add 5 hours to convert your NY time to UTC like below:
<?php
$ny_time = "12:30 am";
$utc_time = strtotime("+5 hours", strtotime($ny_time));
echo date('h:i a', $utc_time); // output 05:30 am
?>

Amit Rajput
- 2,061
- 1
- 9
- 27
1
Simply use gmdate()
function of PHP instead like as
date_default_timezone_set('America/New_York');
echo $script_tz = date_default_timezone_get();
$ny_time = "12:30 am";
echo gmdate('h:i a',strtotime($ny_time));// 05:30 am
gmdate()
is identical to thedate()
function except that the time returned is Greenwich Mean Time (GMT).

Narendrasingh Sisodia
- 21,247
- 6
- 47
- 54