1

I get a JSON feed with GMT time in ISO 8601 format, and I wanted to display it changed to local time.

The script I have is below

$json = json_decode($response,true);

$output = "<ul>";
foreach($json['clients'] as $client){
    $output .= "<h4><p style=color:#FFFFFF;align=center>".$client['timestamp']." ".$date2."</h4>";

}
$output .= "</ul>";

What code can I insert into the foreach part to display each of the timestamps from the JSON feed in local time?

I am in Melbourne Australia so it will be +11 hours.

Thanks All

Rob

Renegade Rob
  • 393
  • 1
  • 4
  • 21

1 Answers1

1

Simply set your timezone using date_default_timezone_set like as

date_default_timezone_set("Australia/Melbourne");
echo date('Y-m-d H:i:s P',strtotime($date2));
Narendrasingh Sisodia
  • 21,247
  • 6
  • 47
  • 54