Jyxo\Time\Util::nextMonth PHP Method

nextMonth() public static method

If the current date is greater than the next month's number of days, returns the next month's last date. This is different from strtotime('+1 month') behaviour, where August 31st returns October 1st.
public static nextMonth ( Time $now = null ) : Time
$now Time Current date/time
return Time
    public static function nextMonth(\Jyxo\Time\Time $now = null) : Time
    {
        $now = $now ? $now->unix : time();
        $nextMonth = date('n', $now) + 1;
        $thisYear = (int) date('Y', $now);
        // Actual date vs. next month's number of days
        $day = min((int) date('j', $now), (int) date('t', mktime(0, 0, 0, $nextMonth, 1, $thisYear)));
        // Create the date
        $date = mktime((int) date('H', $now), (int) date('i', $now), (int) date('s', $now), $nextMonth, $day, $thisYear);
        return new Time($date);
    }