Last active
July 18, 2017 15:55
-
-
Save Ryan4CN/2bb89662432b449cc33258eb67997c93 to your computer and use it in GitHub Desktop.
php timezone
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
<?php | |
/** | |
* install timezonedb | |
* | |
* 1. apt-get install php7.0-dev | |
* 2. pecl install timezonedb | |
* 3. You should add "extension=timezonedb.so" to php.ini | |
* | |
*/ | |
echo $t = '15 Sep 2016 15:48:04 GMT+02:00'; | |
echo $t = '12 Jul 2017 10:44:29 BDT'; | |
echo $t = 'Feb 5, 2017 11:58:27 PM PST'; | |
echo $t = '2017/07/09 16:18:24 JST'; | |
echo $t = 'Jul 2, 2017 10:06:36 PM PDT'; | |
echo $t = '2017-07-18T21:24:41.6565053 +08:00'; | |
echo $t = 'Feb 5, 2017 11:58:27 PM BDT'; | |
echo $t = '21 Oct 2016 23:52:59 GMT+02:00'; | |
echo $t = '2017/07/09 16:18:24 ACT'; | |
echo $t = str_replace('MEST', 'MET', '2017/07/09 16:18:24 MEST'); | |
echo "\n"; | |
$a = new DateTime($t); | |
$a->setTimeZone(new DateTimeZone('UTC')); | |
print_r($a); | |
echo "\n"; | |
// If you get MEST/CEST, you should replace to MET/CET first. | |
// $t = str_replace(['MEST', 'CEST'], ['MET', 'CET'], $t); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment