deib97 Posted January 13, 2014 Share Posted January 13, 2014 I want to input holiday once for next every year. How to schedule a yearly repeating holiday when i change year?. example : Xmas I have a code : <?php for($i=2013; $i<=2020; $i++) { $datetime = new DateTime("$i-12-25 00:00:00"); echo "25 Dec $i<br>"; } ?> Link to comment https://forums.phpfreaks.com/topic/285326-repeat-holiday-every-year/ Share on other sites More sharing options...
Barand Posted January 13, 2014 Share Posted January 13, 2014 $d1 = new DateTime('2013-12-25'); $dp = new DatePeriod($d1, new DateInterval('P1Y'), 7); foreach ($dp as $dt) { echo $dt->format('jS F Y') . '<br>'; } /* OUTPUT ***** 25th December 2013 25th December 2014 25th December 2015 25th December 2016 25th December 2017 25th December 2018 25th December 2019 25th December 2020 */ Link to comment https://forums.phpfreaks.com/topic/285326-repeat-holiday-every-year/#findComment-1465046 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.