- microtime: documentation ( source)
- sleep: documentation ( source)
<?php
class time
{
const second = 1000;
const minute = 60000;
const hour = 3600000;
const day = 86400000;
const week = 604800000;
const month = 18144000000;
static public function now()
{
return microtime(true);
}
static public function since ($time)
{
return microtime(true)-$time;
}
}
$start = time::now();
sleep(2 * time::second);
echo time::since($start);