date(format,timestamp)
<html>
<body>
<?php
header("content-type:text/html;charset=utf-8");
echo "今天是 " . date("Y/m/d") . "<br>";
echo "今天是 " . date("Y.m.d") . "<br>";
echo "今天是 " . date("Y-m-d") . "<br>";
echo "今天是 " . date("l");
?>
</body>
</html>
补充说明:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
版权所有 2009-<?php echo date("Y")?>
</body>
</html>
<!DOCTYPE htmml>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<?php
echo "当前时间是".date("h:i:sa");
?>
</body>
</html>
补充说明:
date_default_timezone_set("Asia/Shanghai");
补充说明:如果从代码返回的不是正确的时间,有可能是因为您的时区设置问题。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<?php
$d=mktime(9,12,31,6,10,2015);
echo "创建日期是 ".date("Y-m-d h:i:sa",$d);
?>
</body>
</html>
语法:strtotime(time,now)
功能:把人类可读的字符串转换为Unxi时间
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; chatset=utf-8" />
</head>
<body>
<?php
header("content-type:text/html;charset=utf-8");
$d=strtotime("10:38pm April 15 2015");
echo "创建日期是".date("Y-m-d h:i:sa",$d);
?>
</body>
</html>
补充说明:(格式灵活)
原文:https://www.cnblogs.com/ceiling-/p/14394458.html