Skip to content

Instantly share code, notes, and snippets.

@galvao
Created December 11, 2020 12:56
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 galvao/579ac489b197ba5d49361b46bfafa895 to your computer and use it in GitHub Desktop.
Save galvao/579ac489b197ba5d49361b46bfafa895 to your computer and use it in GitHub Desktop.
DateTimeImmutable example
<?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