to_time()

函数:to_time()
功能:将日期 / 日期时间 类型转为unix时间戳的函数
位置:帝国CMS e/class/connect.php
版本:6.5

to_time($datetime)

$datetime : 日期类型格式如:2012-12-12 日期时间如:2012-12-12 12:12:12
函数返回unix时间戳

to_time()函数注释

function to_time($datetime)
{

	//2010-06-23
	//10个长度正好是上边的长度
	//下面给补充了空格 时 分 秒
	if(strlen($datetime)==10)
	{
		$datetime.=" 00:00:00";
	}

	//以空格分割了日期和时间
	//0日期
	//1时间
	$r=explode(" ",$datetime);

	//以连接线分割了日期
	//0年
	//1月
	//2日
	$t=explode("-",$r[0]);

	//以英文冒号分割时间
	//0小时
	//1分钟
	//2秒钟
	$k=explode(":",$r[1]);

	//mktime() 函数返回一个日期的 Unix 时间戳
	//mktime(hour,minute,second,month,day,year,is_dst)
	//参数总是表示 GMT 日期,因此 is_dst 对结果没有影响
	//GMT=Greenwich mean time 格林尼治标准时间
	//is_dst 自从php5.1.0就被废弃了
	$dbtime=@mktime($k[0],$k[1],$k[2],$t[1],$t[2],$t[0]);

	//返回UNIX时间戳
	return $dbtime;
}