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
  • 526
  • 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,023
  • 1
  • 8
  • 25
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
  • 20,667
  • 5
  • 43
  • 53