La classe Cake\I18n\Time

← Torna a CakePHP

$time = new Time('2014-04-20 22:10');
$time->i18nFormat(); // outputs '4/20/14, 10:10 PM' for the en-US locale
$time->i18nFormat(\IntlDateFormatter::FULL); // Use the full date and time format
$time->i18nFormat([\IntlDateFormatter::FULL, \IntlDateFormatter::SHORT]); // Use full date but short time format
$time->i18nFormat('yyyy-MM-dd HH:mm:ss'); // outputs '2014-04-20 22:10'
$now = Time::now();
echo $now->year; // 2014
echo $now->month; // 5
echo $now->day; // 10
echo $now->timezone; // America/New_York
echo $time->isYesterday();
echo $time->isThisWeek();
echo $time->isThisMonth();
echo $time->isThisYear();
$time = Time::now();
$time->subMonth( );
$time->subMonths( 2 );
$time->addDay( );
$time->addDays( 2 );

$time->modify('+5 days');

Fine mese

$giornimese = mktime( 0, 0, 0, $time->i18nFormat('MM'), 1, $time->i18nFormat('yyyy') );
$giornimese = date( "t", $giornimese );