PHP – Calculate the next occurrence of any given date

Happy Friday the 13th! Here are some fun facts for you: any month that begins on a Sunday will have a Friday the 13th. Furthermore, Friday the 13th is no different, statistically speaking, than say Tuesday the 17th. That is, they both occur (or don’t occur) the same number of times. Speaking of dates and how often they occur, I threw together a quick PHP function that uses PHP’s DateTime to calculate the next occurrence of any given date.


This post was inspired by the mathematical algorithm known quizzically as the Doomsday Rule, which can be used to calculate the next occurrence for any given date (on the Gregorian calendar.)

Leave a Reply

Your email address will not be published. Required fields are marked *

×Mike Everhart

Need Some More Help? Let's Talk!

I'd love to work with you! Fill out the form below to schedule a free consultation to discuss your needs and how I can help.

Need More Help?