Created
January 8, 2017 14:28
-
-
Save fininhors/6bb18c29260452dbd25eaafd88898644 to your computer and use it in GitHub Desktop.
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 | |
| # calcula as quintas feiras entre duas datas e mostra na tela | |
| $raw = '01. 01. 2017'; | |
| $start = DateTime::createFromFormat('d. m. Y', $raw); | |
| $end = clone $start; | |
| $end->add(new DateInterval('P1M')); | |
| // mostra todas as quintas-feiras entre $start e $end | |
| $periodInterval = DateInterval::createFromDateString('first thursday'); | |
| $periodIterator = new DatePeriod($start, $periodInterval, $end, DatePeriod::EXCLUDE_START_DATE); | |
| foreach($periodIterator as $date) { | |
| //mostra cada data no período | |
| echo $date->format('d/m/Y') . "<br>"; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment