如何找到每月的查找第一个星期日

Piy*_*iya -5 php

我需要每个月的第一个星期日日期使用PHP代码.

请帮帮我.

getSunday();
Run Code Online (Sandbox Code Playgroud)

Man*_*tel 10

这是获得本月第一个星期日的最佳方式

echo date("Y-m-d", strtotime("first Sunday of ".date('M')." ".date('Y').""));
Run Code Online (Sandbox Code Playgroud)


Sve*_*sen 8

您可以使用日期/时间扩展名.

$start    = new DateTime('2012-12-31');
$end      = new DateTime('2013-12-31');
$interval = DateInterval::createFromDateString('first sunday of next month');
$period   = new DatePeriod($start, $interval, $end, DatePeriod::EXCLUDE_START_DATE);
foreach($period as $time) {
    echo $time->format("F jS") . "<br>\n";
}
/*
January 6th 
February 3rd 
March 3rd 
April 7th 
May 5th 
June 2nd 
July 7th 
August 4th 
September 1st 
October 6th 
November 3rd 
December 1st
*/
Run Code Online (Sandbox Code Playgroud)


pho*_*nix 5

我一直在寻找DTS日期,所以这是我的查找方式:

$dtsStart = date('Y-m-d 02:00:00', strtotime('Second Sunday Of March 2015'));
$dtsEnd = date('Y-m-d 02:00:00', strtotime('First Sunday Of November 2015'));
Run Code Online (Sandbox Code Playgroud)