一 代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网页闹钟</title>
</head>
<body>
<?php
$time1 = strtotime(date("Y-m-d")); //当前的系统时间,获取月和天的时间戳
$time2 = strtotime(date("Y")."-01-01"); //设置时间1月1日的时间戳
if($time1==$time2){ //判断两个时间戳是否相同
echo "<script>alert('元旦快乐!');window.location.href='index.php';</script>";//给出提示信息
}else{
echo "今天不是一个特殊的日子!";
}
?>
</body>
</html>
二 运行结果
今天不是一个特殊的日子!