2

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 ).

Gugan Abu
  • 546
  • 1
  • 4
  • 17

2 Answers2

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 the date() function except that the time returned is Greenwich Mean Time (GMT).

Demo

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