You need to display all dates from the current one, and not more than 30 days.

right now

$months = array('Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'); $month_title = $months[$month-1]; $num = cal_days_in_month(CAL_GREGORIAN, $month, $year); for($i=$day;$i<=$num;$i++) { $mktime=mktime(0,0,0,$month,$i,$year); $date = date("Ymd",$mktime); $date2 = date("Ymd",$mktime); $dayweek = strftime("%w", strtotime($date)); $dayweek=str_replace("1","Понедельник",$dayweek); $dayweek=str_replace("2","Вторник",$dayweek); $dayweek=str_replace("3","Среда",$dayweek); $dayweek=str_replace("4","Четверг",$dayweek); $dayweek=str_replace("5","Пятница",$dayweek); $dayweek=str_replace("6","Суббота",$dayweek); $dayweek=str_replace("0","Воскресенье",$dayweek); ?> <div class="tasck-list"> <div class="dc-head <? if (''.$year.''.$month.''.$day.'' == $date2) {echo 'green';}?>" date-datetime="<?=$date;?>"> <div class="dch-title"><?=new_time(strtotime($date));?></div> <div class="dch-week"><?=$dayweek;?></div> </div> <? } ?> 
  • Edit the code, explain what you want with examples. Type of input -> result. - E_p
  • show the full code, with all variables - L. Vadim
  • @ L.Vadim added - Alexander Sizintsev

2 answers 2

 $date = date_create('2017-02-28'); for($i=0;$i<=30;$i++) { echo date_format($date, 'Ym-d'); date_add($date, date_interval_create_from_date_string('1 days')); } 

Details

    Code:

      for ($i=1; $i<=30; $i++) { print date('Ymd, l', time() + 3600 * 24 * $i) . "\n"; } 

    Result:

     2017-03-01, Wednesday 2017-03-02, Thursday 2017-03-03, Friday 2017-03-04, Saturday 2017-03-05, Sunday 2017-03-06, Monday 2017-03-07, Tuesday 2017-03-08, Wednesday 2017-03-09, Thursday 2017-03-10, Friday 2017-03-11, Saturday 2017-03-12, Sunday 2017-03-13, Monday 2017-03-14, Tuesday 2017-03-15, Wednesday 2017-03-16, Thursday 2017-03-17, Friday 2017-03-18, Saturday 2017-03-19, Sunday 2017-03-20, Monday 2017-03-21, Tuesday 2017-03-22, Wednesday 2017-03-23, Thursday 2017-03-24, Friday 2017-03-25, Saturday 2017-03-26, Sunday 2017-03-27, Monday 2017-03-28, Tuesday 2017-03-29, Wednesday 
    • Yoshkin cat, March already) - vp_arth
    • @vp_arth was surprised himself) the first thought was that he was somewhere: D - Dmitry Zasypkin