echo $timeAsItShouldBe; echo "</p>"; } test_time("-2 year", "over 2 years"); timeAgoInWords("-2 year"); test_time("-1 year", "about 1 year"); timeAgoInWords("-1 year"); test_time("-1 month", "about 1 month"); timeAgoInWords("-1 month"); test_time("-2 month", "about 2 months"); timeAgoInWords("-2 month"); test_time("-1 day", "1 day"); timeAgoInWords("-1 day"); test_time("-2 day", "2 days"); timeAgoInWords("-2 day"); test_time("-1 hour", "about 1 hour"); timeAgoInWords("-1 hour"); test_time("-2 hour", "about 2 hours"); timeAgoInWords("-2 hour"); test_time("-1 minute", "about 1 minute"); timeAgoInWords("-1 minute"); test_time("-2 minute", "about 2 minutes"); timeAgoInWords("-2 minute"); test_time("-44 minute", "about 44 minutes"); timeAgoInWords("-44 minute"); test_time("-45 minute", "about 1 hour"); timeAgoInWords("-45 minute"); test_time("-1 second", "less than a minute"); timeAgoInWords("-1 second"); test_time("-31 second", "1 minute"); timeAgoInWords("-31 second");
<?php if (test_time()) { register_shutdown_function('xhprofclose'); xhprof_enable(XHPROF_FLAGS_MEMORY + XHPROF_FLAGS_NO_BUILTINS); } #每个小时的前10秒 function test_time() { $min = date("i"); $sec = date("s"); if ($min == '01' && $sec < "10") { return true; } return false; } function xhprofclose() { $xhprof_data = xhprof_disable(); $xhprof_location = "/data/htdocs/xhprof"; include_once "{$xhprof_location}/xhprof_lib/utils/xhprof_lib.php"; include_once "{$xhprof_location}/xhprof_lib/utils/xhprof_runs.php"; $xhprof_runs = new XHProfRuns_Default(); $identifer = str_replace(array('/', '?', '.', '=', '&'), '_', $_SERVER['REQUEST_URI']); $xhprof_runs->save_run($xhprof_data, $identifer); } define('TOM_EXEC', true); require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config/config.php'; Tom_Core_Autoload::addPath(TOM_MODULES_DIR); Tom_Core_Autoload::addPath(TOM_PLUGINS_DIR); Tom_Core_Context::createInstance()->dispatch();