- time: documentation ( source)
- date: documentation ( source)
- strtotime: documentation ( source)
<?php
$month = 6;
$monthName = date('M', strtotime('2012-'.$month.'-01'));
$to = strtotime('last day of '.$monthName.', 23:59:59');
if ( $to < time() ) {
$to = strtotime('last day of '.$monthName.' '.(date('Y')+1).', 23:59:59');
}
$from = strtotime('first day of this month, 00:00:00', $to);
echo date('d.m.Y H:i:s', $from)."\r\n";
echo date('d.m.Y H:i:s', $to)."\r\n";