Created
May 13, 2021 12:56
-
-
Save Mauryashubham/36bb0ccbc75ca61e0104dd1e3d9489b4 to your computer and use it in GitHub Desktop.
GET PREVIOUS WEEK DATES USING CUSTOM DATE IN PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET PREVIOUS WEEK DATES USING CUSTOM DATE IN PHP</strong></p> | |
@author : Shubham Maurya | |
Email id : [email protected] | |
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