Yogirajsinh Jethwa Yogirajsinh Jethwa - 11 months ago 54
PHP Question

PHP how to get current month date using while loop


  • Is their any way I can get first day of month and last day of month and print whole month date using loop?


Answer Source

This will return current month date using loop automatically pls check...

<?php
     $first_day = date('01-m-Y'); // Start date (First Day of month)
     $last_day = date('t-m-Y'); // End date  (Last Day of Month)
     while (strtotime($first_day) <= strtotime($last_day)) {
            echo "$date<BR>";
            $first_day = date ("d-m-Y", strtotime("+1 day", strtotime($first_day)));
     }
?>