Created
January 15, 2017 16:06
-
-
Save YurePereira/532f53e50e56cea4c06f3d7a7d231171 to your computer and use it in GitHub Desktop.
Alterando o TimeZone já definido de uma data utilizando o método setTimeZone da classe DateTime
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 | |
| $myTimeZone = new DateTimeZone('America/Sao_Paulo'); | |
| $myDate = new DateTime('+2 months', $myTimeZone); | |
| echo $myDate->format('Y-m-d H:i:s A') . PHP_EOL; | |
| $myNewTimeZone = new DateTimeZone('Asia/Dubai'); | |
| $myDate->setTimezone($myNewTimeZone); | |
| echo $myDate->format('Y-m-d H:i:s A'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment