Without more code its difficult to know what you are trying to do. However, I have put together some sample code that you can run from a command line. Perhaps it will give you some ideas.
PHP Code:
<?php
define ('TIME_LIMIT', 15);
date_default_timezone_set('Europe/London');
$time = time();
echo "time [$time]" . PHP_EOL;
$sleep_ret = sleep(TIME_LIMIT);
if ($sleep_ret != 0) {
die ("error: sleep returned non-zero" . PHP_EOL);
}
$current_time = time();
echo "current_time [$current_time]" . PHP_EOL;
$time_diff = $current_time - $time;
if ($time_diff >= TIME_LIMIT) {
echo "time limit exceeded" . PHP_EOL;
$time_diff_array = explode(',' , strftime ("%H,%M,%S", $time_diff));
print_r ($time_diff_array);
# use zero base for hours
echo "total hours [". ($time_diff_array[0]-1) . "]" . PHP_EOL;
echo "total minutes [". $time_diff_array[1] . "]" . PHP_EOL;
echo "total seconds [". $time_diff_array[2] . "]" . PHP_EOL;
}
?>
Bookmarks