How to find the date of a day of the week from a date using PHP?

后端 未结 9 1807
说谎
说谎 2020-11-27 03:59

If I\'ve got a $date YYYY-mm-dd and want to get a specific $day (specified by 0 (sunday) to 6 (saturday)) of the week that YYYY-

9条回答
  •  迷失自我
    2020-11-27 04:33

    Try

    $date = '2012-10-11';
    $day  = 1;
    $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday','Thursday','Friday', 'Saturday');
    echo date('Y-m-d', strtotime($days[$day], strtotime($date)));
    

提交回复
热议问题