您的位置:首页 > 编程语言 > PHP开发

修改PHP的默认时区

2013-03-12 22:53 239 查看
可以在php.ini中设置 date.timezone=""

可以在php公共包含文件中设置 date_default_timezone_set()

值可以是Asia/Shanghai PRC Gtc/GET-8

毫秒获取 microtime

例:

<?php
class Timer{
private $startTime;
private $stopTime;
function __construct(){
$this->startTime=0;
$this->stopTime=0;
}
function start(){
$this->startTime=microtime(true);
echo $this->startTime."<br>";
}
function stop(){
$this->stopTime=microtime(true);
echo $this->stopTime."<br>";
}
function spent(){
return round(($this->stopTime-$this->startTime),4);
}
}
$timer=new Timer;
$timer->start();
usleep(10000);
$timer->stop();
echo $timer->spent();
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: