3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tz = new DateTimeZone('America/New_York'); $date_ranges = array( '7 Days Ago' => array( 'from' => new DateTime('7 days ago 00:00:00', $tz), 'to' => new DateTime('yesterday 23:59:59', $tz) ), 'Yesterday' => array( 'from' => new DateTime('yesterday 00:00:00', $tz), 'to' => new DateTime('yesterday 23:59:59', $tz) ), '30 Days Ago' => array( 'from' => new DateTime('30 days ago 00:00:00', $tz), 'to' => new DateTime('yesterday 23:59:59', $tz) ) ); usort($myArray, function($a, $b) { return $a['from']->getTimestamp() - $b['from']->getTimestamp(); }); print_r($date_ranges);

preferences:
55.53 ms | 402 KiB | 5 Q