<?php function measture_duration(callable $callback) { $start = microtime(true); call_user_func($callback); $duration = microtime(true) - $start; printf("Duration: %s\n\n", number_format($duration, 6)); } function timestamp_lowest(array $array) { return min(array_column($array, 'ts')); } function timestamp_lowest2(array $array) { $values = array_column($array, 'ts'); $values = array_slice($values, 1); return min($values); } $timezone = new DateTimeZone('Europe/Berlin'); $duration = measture_duration(function() use($timezone) { printf("Default Value\n"); $result = $timezone->getTransitions(); $lowest = timestamp_lowest($result); printf("Lowest timestamp: %s (%s)\n", $lowest, date('Y-m-d', $lowest)); $lowest2 = timestamp_lowest2($result); printf("Lowest timestamp2: %s (%s)\n", $lowest2, date('Y-m-d', $lowest2)); }); $duration = measture_duration(function() use($timezone) { $timestamp = 0; printf("Timestamp for %s\n", date('Y-m-d H:i:s', $timestamp)); $result = $timezone->getTransitions($timestamp); $lowest = timestamp_lowest($result); printf("Lowest timestamp: %s (%s)\n", $lowest, date('Y-m-d', $lowest)); }); $duration = measture_duration(function() use($timezone) { $timestamp = -62135596800; printf("Timestamp for %s\n", date('Y-m-d H:i:s', $timestamp)); $result = $timezone->getTransitions($timestamp); $lowest = timestamp_lowest($result); printf("Lowest timestamp: %s (%s)\n", $lowest, date('Y-m-d', $lowest)); });
You have javascript disabled. You will not be able to edit any code.