Skip to content

Instantly share code, notes, and snippets.

@Mauryashubham
Created May 13, 2021 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mauryashubham/36bb0ccbc75ca61e0104dd1e3d9489b4 to your computer and use it in GitHub Desktop.
Save Mauryashubham/36bb0ccbc75ca61e0104dd1e3d9489b4 to your computer and use it in GitHub Desktop.
GET PREVIOUS WEEK DATES USING CUSTOM DATE IN PHP
GET PREVIOUS WEEK DATES USING CUSTOM DATE IN PHP</strong></p>
@author : Shubham Maurya
Email id : maurya.shubham5@gmail.com
Hi all , Welcome to shubhammaurya.com , Today we are going to discuss , how to get previous week dates from a custom date/user given date.
We will use strtotime() function to get all dates.
<?php
// set Custom rent date
$date = strtotime('2021-05-12'); //Custom Date
$previous_monday = strtotime("last week monday",$date);
$previous_friday= strtotime("last week friday",$date);
echo "<br> last week monday : ".date('Y-m-d',$previous_monday)."<br>";
echo "<br> last week friday : ".date('Y-m-d',$previous_friday)."<br>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment