I need help PHP about strtotime.. HELP ME [on hold]

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <body>
        <?php  // range from: 26/09/2015 -> 25/10/2015

        $start_ts = strtotime('26-09-2015');
            $end_ts = strtotime('25-10-2015');
            $current_ts = $start_ts;
            $sat_arr = array();
            $sun_arr = array();
            $sat_day = 0;
            $sun_day = 0;

// check start day
            switch (strtolower(date('l', $start_ts))) {
                case 'saturday':
                    $sat_arr[] = date('Y-m-d', $start_ts);
                    $sat_day++;
                    break;
                case 'sunday':
                    $sun_arr[] = date('Y-m-d', $start_ts);
                    $sun_day++;
                    break;

                default:
                    break;
            }

            while ($current_ts < $end_ts) {
                if (($current_ts = strtotime('next saturday', $current_ts)) < $end_ts) {
                    $sat_arr[] = date('Y-m-d', $current_ts);
                    $sat_day++;
                }
                if (($current_ts = strtotime('next sunday', $current_ts)) < $end_ts) {
                    $sun_arr[] = date('Y-m-d', $current_ts);
                    $sun_day++;
                }
            }
        // check end day    
        switch (strtolower(date('l', $end_ts))) {
                case 'saturday':
                    $sat_arr[] = date('Y-m-d', $end_ts);
                    $sat_day++;
                    break;
                case 'sunday':
                    $sun_arr[] = date('Y-m-d', $end_ts);
                    $sun_day++;
                    break;

                default:
                    break;
            }


            echo "<pre>";
            print_r($sat_arr);
            print_r($sat_day); 
            print_r($sun_arr);
            print_r($sun_day);

            echo "</pre>";
    </body>
    </html>

The formula is : result 5 Saturdays and 5 Sundays

but : right on the calendar to 5 Saturdays and 5 Sundays

Where’s problems ? ( 27/9 /2015 = > ???? )

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s