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; echo "date - $time (100%)\n"; $ttime = $time; $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 - ", round($time, 10), " (", round(100*$time/$ttime, 2), "%)\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 - ", round($time, 10), " (", round(100*$time/$ttime, 2), "%)\n";
Show:  
Copy Clear