How to calculate Mother’s Day and Father’s Day with PHP

A little late on the Mother’s Day part, but since today is Father’s Day, I figured it would be fun to discuss how to obtain the dates for these moving holidays. To do so, all we need to use is use strtotime and tell it when the holiday will occur as well as the year that we want to get the holiday in.

Mother’s Day

Mother’s Day in the United States is held annually on the second Sunday of May.

echo date('Y-m-d', strtotime('second Sunday of May 2014'

Father’s Day

Father’s Day in the United States is held annually on the third Sunday of June.

echo date('Y-m-d', strtotime('third Sunday of June 2014'

That’s all there is to it! Happy Father’s Day to all my fellow dads out there, and happy belated Mother’s Day to all the ladies!

Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

If you found this article helpful, please consider buying me a coffee.