Retrieving Day Names in PHP

前端 未结 7 597
-上瘾入骨i
-上瘾入骨i 2021-01-11 15:44

I need to display to user a list of localized day names (like \'Monday\', \'Tuesday\', ...) in a form. I know ho to get day name of any date. But is there a particular and f

7条回答
  •  时光说笑
    2021-01-11 16:14

    The "usual" way is to start with a given last day and count up a day on each iteration.

    for ($i = 0; $i < 7; $i++) {
      $weekDayNames[] = strftime("%a", strtotime("last sunday +$i day"));
    }
    

提交回复
热议问题