In this tutorial you will learn how to find PHP date of last sunday in a PHP web application.
PHP date get last Sunday
In this tutorial you will learn how to find PHP date of last sunday in a PHP web application. In this tutorial $date variable first assign current date and again use strtotime() function that return Unix timestamp . When pass parameter in strtotime($date.'last sunday') dunction then it return's last Sunday Unix timestamp and last it's value pass in date() with date format , it get date last Sunday . The code of "php-date-get-last-sunday.php" given below as :
<?php $date=date("Y-m-d"); echo "Current Date : ".$date."<br>"; echo "last Sunday : ".date('Y-m-d', strtotime($date.'last sunday')); ?>
Output :
When run "php-date-get-last-sunday.php" display output as :
[ 0 ] Comments