これはどうやってやろうとしています...しかし、2017年に60日間の増分が6月を超えるとどうなりますか?
コード(Demo):
は
$today=strtotime('today');
//$min=strtotime('first day of this month');
$max=strtotime('last day of this month');
$prevs=['1994-06-01','1994-06-7','1994-06-14','1994-06-15','1994-06-17','1994-06-21','1994-06-30'];
foreach($prevs as $prev){
echo "prev = ",$prev = strtotime($prev),"\n";
echo "diff = ",$diff=$today-$prev,"\n"; // calculate seconds between two dates
// add just enough seconds (in 60 day increments) to reach at least $min
echo "newseconds = ",$newseconds=$prev+5184000*ceil($diff/5184000),"\n"; // 60 days in seconds
if($newseconds>$max){echo "Warning: new incremented date not in input month\n";} // handle this exception?
echo "newdate = ",date("Y-m-d",$newseconds),"\n\n";
}
出力:
prev = 770454000
diff = 727056000
newseconds = 1501398000
Warning: new incremented date not in input month
newdate = 2017-07-30
prev = 770972400
diff = 726537600
newseconds = 1501916400
Warning: new incremented date not in input month
newdate = 2017-08-05
prev = 771577200
diff = 725932800
newseconds = 1502521200
Warning: new incremented date not in input month
newdate = 2017-08-12
prev = 771663600
diff = 725846400
newseconds = 1502607600
Warning: new incremented date not in input month
newdate = 2017-08-13
prev = 771836400
diff = 725673600
newseconds = 1497596400
newdate = 2017-06-16
prev = 772182000
diff = 725328000
newseconds = 1497942000
newdate = 2017-06-20
prev = 772959600
diff = 724550400
newseconds = 1498719600
newdate = 2017-06-29
数学はここで働いてます私はこの発生を公開するデモを設定しています。 diff b/w 2の日付を見つけ、そのdiffを分割します。あなたのセットに基づいて:ex:today-prev = diff; diff/number_of_setがあなたのxになります – Santosh
各エントリごとに毎日または最終日にしますか? –
最終日、つまり最近の日付はどうなりますか? –