Yogirajsinh Jethwa Yogirajsinh Jethwa - 1 year ago 76
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...

     $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)));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download