I am trying to find the closest previous Sunday to a date (unless date is Sunday).
So for example, if I have this array:
$dates = array(
"2014-03-02 10:15:10", // sun
"2014-03-03 12:15:10", // mon
"2014-03-04 13:15:10", // tue
"2014-03-05 10:15:10", // wed
"2014-03-06 14:15:10", // thu
"2014-03-07 18:15:10", // fri
"2014-03-08 14:15:10", // sat
"2014-03-09 14:15:10" // sun
);
How can I efficiently output this:
$dates = array(
"2014-03-02 00:00:00", // sun
"2014-03-02 00:00:00", // sun
"2014-03-02 00:00:00", // sun
"2014-03-02 00:00:00", // sun
"2014-03-02 00:00:00", // sun
"2014-03-02 00:00:00", // sun
"2014-03-02 00:00:00", // sun
"2014-03-09 00:00:00" // sun
);