php日期函数

来源:互联网 发布:java getname 编辑:程序博客网 时间:2024/05/16 03:59

<html>
<head><title>非法字符的处理</title></head>
<body>
<?php
echo time();//输出从1970年1月1日0时0分0秒到当前时间的秒数(时间戳)
echo "<br>";
echo mktime(23,56,59,12,20,1999);//输出指定时间(时分秒月日年)的时间戳
echo mktime(23,56,59,13,20,1999);//时间超出,往下推算
echo "<br>############strtotime函数##########<br>";
echo strtotime("2009-10-12 20:20:29");//把指定的时间日期转化为时间戳,月日年的连接
//只能用-或者/,时分秒的连接只能是:
echo strtotime("2009/10/12 20/20/29");//无法输出
echo "<br>############getdate、date函数##########<br>";
print_r(getdate());//返回当前时间戳下日期数组,默认为当前时间戳
$arrtime=getdate(strtotime("2009-10-12 20:20:29"));//返回指定日期时间戳的数组
echo "<br>";
echo $arrtime["minutes"];
echo "<br>";
echo date("Y‖m‖d H‖i‖s A");//输入指定日期时间戳的日期格式,默认为当前时间戳
echo "<Br>";
echo date("Y年m月d日 H时i分s秒 A",strtotime("2009-10-12 20:20:29"));
?>
</body>
</html>

原创粉丝点击