Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to get last week date range in PHP

by
Category:php
php
How to get last week date range in PHP

This is a short guide on How to get last week date range monday to sunday in PHP. This is useful for whenever you need to figure out what date a particular date fell on (or will fall on in the future). In this tutorial, I will be retrieving the date from a YYYY-MM-DD string. You may also like How get one week date using PHP and How to Add Days to Date in PHP.

PHP Code

<?php
    $previous_week = strtotime("-1 week +1 day");
    $start_week = strtotime("last monday midnight",$previous_week);
    $end_week = strtotime("next sunday",$start_week);

    $start_week = date("Y-m-d",$start_week);
    $end_week = date("Y-m-d",$end_week);

    echo $start_week.'<br /> '.$end_week ;
?>

0 Comments


Html code work in comment box


Related Post