复制代码 代码如下:
echo mktime(11,25,0,9,5,2010);//和time一样的
echo microtime();
echo mktime(0,0,0,1,1,1970);
?>
复制代码 代码如下:
echo date ("H i l d F" ,1283657100);
echo gmdate("H i l d F",1283657100);
echo strftime("%Hh%M %A %d %b" ,1283657100);
//strftime()工作的方式和date()没有什么不同,除了特殊格式化字符的前面必须添加一个百分号%。
echo strtotime("2010-9-5 11:25:00");
var_dump(getdate (time()));
?>
复制代码 代码如下:
//时间格式化
function sgmdate($dateformat, $timestamp='', $format=0) {
global $_SCONFIG, $_SGLOBAL;
if(empty($timestamp)) {
$timestamp = $_SGLOBAL['timestamp'];
}
$timeoffset = strlen($_SGLOBAL['member']['timeoffset'])>0?intval($_SGLOBAL['member']['timeoffset']):intval($_SCONFIG['timeoffset']);
$result = '';
if($format) {
$time = $_SGLOBAL['timestamp'] - $timestamp;
if($time > 24*3600) {
$result = gmdate($dateformat, $timestamp + $timeoffset * 3600);
} elseif ($time > 3600) {
$result = intval($time/3600).lang('hour').lang('before');
} elseif ($time > 60) {
$result = intval($time/60).lang('minute').lang('before');
} elseif ($time > 0) {
$result = $time.lang('second').lang('before');
} else {
$result = lang('now');
}
} else {
$result = gmdate($dateformat, $timestamp + $timeoffset * 3600);
}
return $result;
}
复制代码 代码如下:
echo date("M d Y H:i:s", mktime(0, 0, 0, 1, 1, 1998));
echo gmdate("M d Y H:i:s", mktime(0, 0, 0, 1, 1, 1998));
?>
复制代码 代码如下:
//字符串时间化
function sstrtotime($string) {
global $_SGLOBAL, $_SCONFIG;
$time = '';
if($string) {
$time = strtotime($string);
if(gmdate('H:i', $_SGLOBAL['timestamp'] + $_SCONFIG['timeoffset'] * 3600) != date('H:i', $_SGLOBAL['timestamp'])) {
$time = $time - $_SCONFIG['timeoffset'] * 3600;
}
}
return $time;
}