function convertDateTime($unixTime) {
$dt = new DateTime("@$unixTime");
return $dt->format('Y-m-d H:i:s');
}
$dateVarName = convertDateTime(1385615749);
echo $dateVarName;
输出:
2013-11-28 05:15:49
<?php
$date = new DateTime();
$dateStamp = $_SERVER['REQUEST_TIME'];
$date->setTimestamp($dateStamp);
echo $date->format('U = Y-m-d H:i:s') . "\n";
?>
you can try this
<?php
$date = date_create();
$dateStamp = $_SERVER['REQUEST_TIME'];
date_timestamp_set($date, $dateStamp);
echo date_format($date, 'U = D-M-Y H:i:s') . "\n";
?>
REQUEST_TIME
- 它是 Unix 时间戳 - 请求开始时的时间戳。
$dateStamp = $_SERVER['REQUEST_TIME'];
echo date('d m Y', $dateStamp);
或者
$date = new DateTime($dateStamp);
echo $date->format('Y-m-d');
这段代码将适用于您
$dateStamp = $_SERVER['REQUEST_TIME'];
echo date('d-M-Y H:i:s',strtotime($dateStamp));
human_time_diff
函数。 - Burhan Khalid