3v4l.org

run code in 300+ PHP versions simultaneously
<?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";

preferences:
29.1 ms | 402 KiB | 5 Q