Created
January 7, 2017 15:47
-
-
Save YurePereira/14cccec17019e7cd7576b0671b98cfa5 to your computer and use it in GitHub Desktop.
Comparando condicionalmente duas 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 | |
| $now = new DateTime(); | |
| $today = new DateTime('today'); | |
| $yesterday = new DateTime('yesterday'); | |
| $tomorrow = new DateTime('tomorrow'); | |
| if ($now >= $today) { | |
| echo $now->format('d/m/Y H:i:s') . ' it greater ' . $today->format('d/m/Y H:i:s') . PHP_EOL; | |
| } | |
| if ($yesterday <= $tomorrow) { | |
| echo $yesterday->format('d/m/Y H:i:s') . ' it smaller ' . $tomorrow->format('d/m/Y H:i:s') . PHP_EOL; | |
| } | |
| if ($today != $tomorrow) { | |
| echo $today->format('d/m/Y H:i:s') . ' is different from ' . $tomorrow->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