PHP: How to get Sunday and Saturday given a date input?

后端 未结 10 1818
终归单人心
终归单人心 2020-12-15 12:15

How can I get the Sunday and Saturday of the week given a specific date?

For example:

input: Monday, September 28, 2009

output should be:

10条回答
  •  甜味超标
    2020-12-15 12:32

    setISODate(2009, $datetime->format("W"), 6);
    print "Saturday:" . $datetime->format(DATE_ATOM) . "\n";
    // Sunday
    $datetime->setISODate(2009, $datetime->format("W"), 0);
    print "Sunday: " . $datetime->format(DATE_ATOM) . "\n";
    
    
    ?>
    

提交回复
热议问题