Skip to content

Instantly share code, notes, and snippets.

@333crist
Created November 18, 2018 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 333crist/7a0385ea81bc0c86a3df9e271838b370 to your computer and use it in GitHub Desktop.
Save 333crist/7a0385ea81bc0c86a3df9e271838b370 to your computer and use it in GitHub Desktop.
Converting UTC to Local Time PHP
<?php
//Standart waktu di Indonesia
date_default_timezone_set('Asia/Jakarta');
//Contoh Variable Waktu dengan format UTC
$timeutc = "2018-09-17T00:20:00Z";
//CONVERT UTC TO LOKAL dengan format tgl/bln/thn jam:menit:detik
$time1 = strtotime($timeutc.' UTC');
$format1 = date("Y-m-d H:i:s", $time1);
//CONVERT UTC TO LOKAL dengan format hanya jam:menit:detik
$time2 = strtotime($timeutc.' UTC');
$format2 = date("H:i:s", $time2);
echo "Contoh Konversi 1 : $format1 <br> Contoh Konversi 2 : $format2";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment