PHP: Latest day of a month using PHP 5

Published at 20 May 2009 by soywiz

// Previous month:  
date_create(date('Ym01'))->modify('-1 day')  

// This month:  
date_create(date('Ym01'))->modify('+1 month -1 day')  

// From a specific month via timestamp:  
date_create(date('Ym01', $timestamp))->modify('+1 month -1 day')  
// Mes anterior:  
date_create(date('Ym01'))->modify('-1 day')  

// Este mes:  
date_create(date('Ym01'))->modify('+1 month -1 day')  

// Un mes concreto mediante timestamp:  
date_create(date('Ym01', $timestamp))->modify('+1 month -1 day')