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 < 50; $i++) { $timestamps[] = mt_rand(strtotime('1900-01-01'), strtotime('2100-12-31 11:59:59 pm')); } print_r($timestamps); $res = array_reduce( $timestamps, function($res, $t) { $time = (date('H:i:s', $t)); if (is_null($res['min'][0]) || $time<$res['min'][0]) $res['min'] = [$time, $t]; if (is_null($res['max'][0]) || $time>$res['max'][0]) $res['max'] = [$time, $t]; return $res; }, ['min'=>[null, null], 'max'=>[null, null]] ); print_r($res);
Show:  
Copy Clear