Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iron-viper/a0452465a955aa6a81c336d4999a9271 to your computer and use it in GitHub Desktop.
Save iron-viper/a0452465a955aa6a81c336d4999a9271 to your computer and use it in GitHub Desktop.
$dateNow = "04/28/2016";
$timestamp = strtotime($dateNow);
$currDayOfWeek = date("w", $timestamp);
$startDayOflastWeekT = strtotime(-($currDayOfWeek + 7) . " days", $timestamp);
$startDayOflastWeek = date("m/d/Y", $startDayOflastWeekT);
$endDayOflastWeekT = strtotime("+ 6 days", $startDayOflastWeekT);
$endDayOflastWeek = date("m/d/Y", $endDayOflastWeekT);
$startDayOfMiddleWeekT = strtotime("+ 7 days", $startDayOflastWeekT);
$startDayOfMiddleWeek = date("m/d/Y", $startDayOfMiddleWeekT);
$endDayOfMiddleWeekT = strtotime("+ 13 days", $startDayOflastWeekT);
$endDayOfMiddleWeek = date("m/d/Y", $endDayOfMiddleWeekT);
$startDayOfNextWeekT = strtotime("+ 14 days", $startDayOflastWeekT);
$startDayOfNextWeek = date("m/d/Y", $startDayOfNextWeekT);
$endlastDayOfNextWeekT = strtotime("+ 21 days", $startDayOflastWeekT);
$endlastDayOfNextWeek = date("m/d/Y", $endlastDayOfNextWeekT);
echo $startDayOflastWeek . " - " . $endDayOflastWeek . "\r\n";
echo $startDayOfMiddleWeek . " - " . $endDayOfMiddleWeek . "\r\n";
echo $startDayOfNextWeek . " - " . $endlastDayOfNextWeek . "\r\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment