/**
* 通过UTC获取精确时间,默认为北京时间
* @param int $timezone
* @param int $timestamp
* @return bool|false|string
*/
public function getutctime($timezone = 8, $timestamp = 0) {
$fp = fsockopen('time.nist.gov', 13, $err_no, $err_str, 90);
$t = fread($fp, 2096);
if (!strlen($t)) return false;
$arr = explode(" ", $t);
$t = dateadd('hour', $timezone, strtotime($arr[1] . " " . $arr[2]));
return $timestamp ? $t : date("Y-m-d H:i:s", $t);
}
文章评论