Get the date of next monday, tuesday, etc

前端 未结 10 1194
轻奢々
轻奢々 2020-11-29 02:24

I would like to find the date stamp of monday, tuesday, wednesday, etc. If that day hasn\'t come this week yet, I would like the date to be this week, else, next week. Thank

10条回答
  •  孤街浪徒
    2020-11-29 03:04

    See strtotime()

    strtotime('next tuesday');
    

    You could probably find out if you have gone past that day by looking at the week number:

    $nextTuesday = strtotime('next tuesday');
    $weekNo = date('W');
    $weekNoNextTuesday = date('W', $nextTuesday);
    
    if ($weekNoNextTuesday != $weekNo) {
        //past tuesday
    }
    

提交回复
热议问题