查找两个日期之间的每个星期日 [英] Find every Sunday between two dates

查看:75
本文介绍了查找两个日期之间的每个星期日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有$fromdate$todate变量.我想要一个可以计算PHP中$fromdate$todate之间每个星期日的日期的函数.

I have $fromdate and $todate variables. I want a function that can calculate the dates of each Sunday existing in between $fromdate and $todate in PHP.

推荐答案

假定这些是日期对象,从$ fromdate开始,向其中添加一天,直到该日期为周日,并且该日期在$ todate之前.在找到的每个星期日中添加7天,添加该日期,并在新日期早于$ todate之前继续进行.跟踪以这种方式找到的每个日期.

Assuming these are date objects, start at $fromdate, add one day to it, until that date is Sunday, and as long as the date is before $todate. Add 7 days to each Sunday you find, add that date and continue as long as the new date is before $todate. Keep track of each date found this way.

这篇关于查找两个日期之间的每个星期日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆