php first monday after certain date as string

后端 未结 2 429
执念已碎
执念已碎 2020-12-20 18:33

I have a date given as a string. And I would like to get the first monday after this given date, again as a string.

$myDate = \"2014-08-24\"; // date given i         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-20 19:06

    You can do it using the DateTime and DateTime::modify

    $date = new DateTime('2014-08-24');
    $date->modify('next monday');
    echo $date->format('Y-m-d') . "\n";
    

提交回复
热议问题