Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何收集将落在特定日期输入上的日期_Javascript_Php_Arrays - Fatal编程技术网

Javascript 如何收集将落在特定日期输入上的日期

Javascript 如何收集将落在特定日期输入上的日期,javascript,php,arrays,Javascript,Php,Arrays,我只是想问你对如何收集日期有什么想法 样本: Sunday = ['12/03/2017','12/10/2017','12/17/2017','12/24/2017','12/31/2017'....]; 它收集了周日的所有日期 javascript或php中是否有一个函数可以帮助我,或者我应该手动执行 感谢您对JAVASCRIPT的建议使用矩.js 你的问题与这篇文章有关 对于PHP使用函数date($format,$timestamp)然后使用formatl(小写字母“l”)一周中某一

我只是想问你对如何收集日期有什么想法

样本:

Sunday = ['12/03/2017','12/10/2017','12/17/2017','12/24/2017','12/31/2017'....];
它收集了周日的所有日期

javascript
php
中是否有一个函数可以帮助我,或者我应该手动执行


感谢您对JAVASCRIPT

的建议使用矩.js

你的问题与这篇文章有关

对于PHP使用函数
date($format,$timestamp)
然后使用format
l(小写字母“l”)
一周中某一天的完整文本表示形式

if(date('l', $date) == 'Sunday'){};
请参阅php中的完整文档

我想首先选择你想开始收藏的最短和最长日期。 例如:

将此转换为时间

$stime = strtotime($s); 
$etime=strtotime($e);
第一个星期天

$sunday = strtotime('next sunday', $stime); 

$format = 'Y-m-d'; 
用第一个星期天初始化数组

$sun=array(date($format, $sunday));
使用while循环检查并生成星期天日期的数组

while($sunday<$etime){
$sunday=strtotime('next sunday', $sunday);
array_push($sun, date($format, $sunday));
}

Print_r($sun);

while($sundayphp的另一个选项是使用2并循环遍历它们之间的所有星期日。您可以使用设置范围并指定日期的格式

例如:

$dayStart = new DateTime('12/03/2017');
$dayEnd = new DateTime();
$dayEnd->modify("+1 month");
$sundays = [];

for ($dayCurrent = $dayStart; $dayCurrent <=$dayEnd; $dayCurrent->modify('next sunday')) {
    array_push($sundays, $dayCurrent->format('m/d/Y'));
}
$dayStart=新日期时间('12/03/2017');
$dayEnd=新的日期时间();
$dayEnd->modify(“+1个月”);
$sundays=[];
对于($dayCurrent=$dayStart;$dayCurrent modify('next sunday')){
数组推送($sundays,$dayCurrent->格式('m/d/Y');
}

仅限本月?为什么不投票?而不是说出解决方案。
while($sunday<$etime){
$sunday=strtotime('next sunday', $sunday);
array_push($sun, date($format, $sunday));
}

Print_r($sun);
$dayStart = new DateTime('12/03/2017');
$dayEnd = new DateTime();
$dayEnd->modify("+1 month");
$sundays = [];

for ($dayCurrent = $dayStart; $dayCurrent <=$dayEnd; $dayCurrent->modify('next sunday')) {
    array_push($sundays, $dayCurrent->format('m/d/Y'));
}