Last active
May 29, 2021 20:00
-
-
Save batazo/ad8b44528283eccbfffd95141388109e to your computer and use it in GitHub Desktop.
DateTimeImmutable vs Namespace
This file contains hidden or 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 | |
| $datetime = new DateTimeImmutable(); | |
| $timestamp = $datetime->getTimestamp(); | |
| echo $timestamp; | |
| // OUTPUT: Actual timestamp | |
| <?php | |
| namespace Application; | |
| $datetime = new DateTimeImmutable(); | |
| $timestamp = $datetime->getTimestamp(); | |
| echo $timestamp; | |
| // OUTPUT: Fatal ERROR | |
| <?php | |
| namespace Application; | |
| $datetime = new \DateTimeImmutable(); | |
| $timestamp = $datetime->getTimestamp(); | |
| echo $timestamp; | |
| // OUTPUT: Actual timestamp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment