- date: documentation ( source)
- strtotime: documentation ( source)
- date_format: documentation ( source)
<?php
$correctTimestamp = correctMondayTimestamp();
$time_query = "data_ordine BETWEEN DATE('".date("Y-m-d",$correctTimestamp)."') AND DATE_ADD(DATE('".date("Y-m-d",strtotime("sunday this week"))."'), INTERVAL 1 DAY)";
$begin = new DateTime(date("c", $correctTimestamp));
echo "TQ: $time_query\nB: ".date_format('U',$begin);
function correctMondayTimestamp(){
if(date('N') == 7) {
return strtotime('monday last week');
} else {
return strtotime('monday this week');
}
}