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>"; } ?> Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted January 13, 2014 Solution 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 */ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.