Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$timestamps = array();
for ($i = 0; $i < 5000; $i++) {
$timestamps[] = mt_rand(strtotime('1900-01-01 00:00:00 am'), strtotime('2100-12-31 11:59:59 pm'));
}
$res = array_reduce(
$timestamps,
function($res, $t) {
$time = strtotime('h:i:s a', $t);
if (is_null($res['min'][0]) || $time<$res['min'][0])
$res['min'] = [$time, date('Y-m-d h:i:s a', $t)];
if (is_null($res['max'][0]) || $time>$res['max'][0])
$res['max'] = [$time, date('Y-m-d h:i:s a', $t)];
return $res;
},
['min'=>[null, null], 'max'=>[null, null]]
);
print_r($res);