Question

Can i convert GMT to IST in PHP without using PEAR.

Here is how i get GMT gmdate(), now how do i convert it to IST.

Thanks

Was it helpful?

Solution

try

 echo date('Y-m-d H:i:s',strtotime('+330 minutes', 0));  

or

  date_default_timezone_set('Asia/Kolkata');
  echo date('Y-m-d H:i:s');  

first get time by

 $time = new DateTime('now', new DateTimeZone('UTC'));
    // than convert it to IST by
    $time->setTimezone(new DateTimeZone('IST'));

OTHER TIPS

Easy-peasy:

$date = new DateTime('2012-11-04 05:04:00', new DateTimeZone('GMT'));
$date->setTimezone(new DateTimeZone('IST'));

echo $date->format('Y-m-d H:i:s');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top