Created
December 11, 2020 12:56
-
-
Save galvao/579ac489b197ba5d49361b46bfafa895 to your computer and use it in GitHub Desktop.
DateTimeImmutable example
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 | |
$now = new DateTime(); | |
$freeze = new DateTimeImmutable(); | |
$now->setTimeZone(new DateTimeZone('UTC')); | |
$freeze->setTimeZone(new DateTimeZone('UTC')); | |
echo $now->format('Y-m-d H:i:s P'); | |
// 2020-12-11 12:50:48 +00:00 | |
$freeze->format('Y-m-d H:i:s P'); | |
// 2020-12-11 09:50:51 -03:00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment