小编int*_*vus的帖子

获取明年周一和周二的所有日期

我需要从当前日期输出接下来12个月的日期列表(仅周一和周二),如下所示:

2010年1月
12日2010年1月12日
星期一2010 年1月18日
星期二2010 年1月19日
星期一2010 年1月25日2010年
2月
2日2010 年2月2日
星期一2010年2月8日星期二2010年2月
9日
星期一2010年2月15日
星期二2010 年2月16日
星期一2010 年2月22

星期二2010年3月9 日星期二
2010
年3月15日星期一2010年3月16 日星期二
......

作为PHP的新手我认为strtotime并在接下来的52周内循环是最好的方法.

$blockedDatesInput = "08 Mar 2010,12 Apr 2010"; // dont show these dates
$blockedDates = explode ("," , $blockedDatesInput); // convert to array
$currentMonth = ""; // current month marker

// loop over the next 52 weeks to find Mondays and Tuesdays
for($i=0; $i<=52; $i++){
// build the month header
$monthReference = …
Run Code Online (Sandbox Code Playgroud)

php strtotime

9
推荐指数
1
解决办法
5986
查看次数

标签 统计

php ×1

strtotime ×1