Last active
June 19, 2019 14:52
-
-
Save YurePereira/d0faba6bacd3e175b4e77fa9ed4cfcee to your computer and use it in GitHub Desktop.
Usando Period Designators com DateInterval para alterar datas
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 DateTime('2016-12-01 00:00:01'); | |
| echo $dateTime->format('d/m/Y H:i:s'), PHP_EOL; | |
| $dateTime->add(new DateInterval('P1YT10H55S')); | |
| echo $dateTime->format('d/m/Y H:i:s'), PHP_EOL; | |
| $dateTime->sub(new DateInterval('PT5H30M20S')); | |
| echo $dateTime->format('d/m/Y H:i:s'), PHP_EOL; | |
| $dateTime->add(new DateInterval('P1Y4M10DT2H30M50S')); | |
| echo $dateTime->format('d/m/Y H:i:s'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment