PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $date = '01.11.2017'; $time_start = microtime(true); for ($i = 1; $i < 100000; $i++) { $timestamp = strtotime($date); $year = date('Y', $timestamp); } $time_end = microtime(true); $time = $time_end - $time_start; $ttime = $time; echo "date - ", number_format((float)$time, 5, '.', ''), " (", number_format($time/$ttime*100, 2, '.', ''), "%) - $year\n"; $time_start = microtime(true); for ($i = 1; $i < 100000; $i++) { list(,,$year) = explode('.', $date); } $time_end = microtime(true); $time = $time_end - $time_start; echo "list - ", number_format((float)$time, 5, '.', ''), " (", number_format($time/$ttime*100, 2, '.', ''), "%) - $year\n"; $time_start = microtime(true); for ($i = 1; $i < 100000; $i++) { $year = explode('.', $date); $year = end($year); } $time_end = microtime(true); $time = $time_end - $time_start; echo " end - ", number_format((float)$time, 5, '.', ''), " (", sprintf("% 6.2f", $time/$ttime*100), "%) - $year\n";
Show:  
Copy Clear