Re: Function mktime() documentation question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 8, 2012 at 7:01 AM, Simon Schick
<simonsimcity@xxxxxxxxxxxxxx> wrote:
> $date = new DateTime($year . '-' . $current_month . '-1');
> $date->add( new DateInterval( 'P1M' ) ); // Add a period of 1 month to
> the date-instance (haven't tried that with the 30th of Jan ... would
> be kind-of interesting)
>
> $days_in_current_month = $date->format('j'); // Get the date of the month

I think you'd need to subtract it with 1 day

date_create(date('Y-m'))->add(new DateInterval('P1M'))->sub(new
DateInterval('P1D'))->format('d');

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux