<?phpheader("Content-type:text/html;charset=utf-8");date_default_timezone_set("PRC");//PHP提供了内置函数time()来取得服务器当前时间的时间戳。$curtime=time();echo$curtime;echo"<hr/>";//date()函数用于格式化时间,返回一个字符串$date=date("Y-m-dH:i",$curtime);echo$date;echo"<hr/>";//mktime()函数用于从日期取得时间戳,成功返回时间戳,否则返回FALSE//mktime(时,分,秒,月,日,年)$mktime=mktime("21","50","18","12","30","2015");echo$mktime;echo"<hr/>";$datetime=date("Y-m-dH:i",$mktime);echo$datetime;echo"<hr/>";//strtotime()函数用于将英文文本字符串表示的日期转换为时间戳$strtime="2015-10-1112:10";$timestr=strtotime("$strtime");echo$timestr;echo"<hr/>";echodate("Y-m-dH:i",$timestr);echo"<hr/>";//要求用户在登陆网站在2小时后失效而需要重新登录的例子$expiration=time()+2*3600;//得到当前时间延迟2小时候的时间戳echo$expiration;?>