PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?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 = date('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);
Show:  
Copy Clear