Yogirajsinh Jethwa Yogirajsinh Jethwa - 24 days ago 8
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

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)));
     }
?>
Comments