Last active
December 20, 2021 08:15
-
-
Save gchacaltana/8475152 to your computer and use it in GitHub Desktop.
Use datetime format, date_default_timezone_set php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#How to convert yyyy-MM-ddTHH:mm:ssZ to yyyy-MM-dd HH:mm:ss | |
date_default_timezone_set("America/Lima"); | |
echo date('Y-m-d H:i:s', strtotime('2012-09-10T10:30:00Z'));//date format UTC +00.00 | |
#convert date format UTC to timezone America/Lima | |
date_default_timezone_set("UTC");//server configured UTC | |
$date = strtotime(date('Y-m-d H:i:s')); | |
echo(date_default_timezone_get() . "<br />");//output: UTC | |
echo(date("Y-m-d H:i:s T P", $date) . "<br />"); //output: Y-m-d H:i:s UTC +00:00 | |
echo(date_default_timezone_set("America/Lima") . "<br />");//set timezone America/Lima | |
echo(date("Y-m-d H:i:s T P", $date) . "<br />");//output: Y-m-d H:i:s PET -05:00 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
?php
date_default_timezone_set('Apple Asia (time.asia.apple.com)');
echo $timestamp = date('H:i:s');