用php写一个简单低配版的万年历
来源:互联网 发布:淘宝上卖的龙钞真假 编辑:程序博客网 时间:2024/05/16 15:32
<?php
//当前年
$year=$_GET['y']?$_GET['y']:date('Y');
//当前月
$month=$_GET['m']?$_GET['m']:date('m');
//当前月1号的时间戳
$firstday=strtotime("{$year}-{$month}-1");
//当前月天数
$days=date('t',$firstday);
//当前月1号是周几
$week=date('w',$firstday);
// echo "$week";
// 上一年和上一月
$prevyear=$year;
$prevmonth=$month-1;
if($prevmonth<1){
$prevyear=$year - 1;
$prevmonth=12;
}
// 下一年和下一月
$nextyear=$year;
$nextmonth=$month+1;
if($nextmonth>12){
$nextyear=$year + 1;
$nextmonth=1;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
font-family:微软雅黑;
}
a{
text-decoration:none;
color:#55f;
}
</style>
</head>
<body>
<center>
<h2>万年历-<?php echo $year ?>年<?php echo $month ?>月</h2>
<table border="1px" cellspacing="0" width="700px">
<thead>
<tr>
<th>周日</th>
<th>周一</th>
<th>周二</th>
<th>周三</th>
<th>周四</th>
<th>周五</th>
<th>周六</th>
</tr>
</thead>
<?php
for($i=(1-$week);$i<=$days;){
echo '<tr>';
for($j=0;$j<7;$j++,$i++){
if($i>$days || $i<1){
echo "<td> </td>";
}else{
echo "<td>{$i}</td>";
}
}
echo '</tr>';
}
?>
</table>
<h3>
<a href="new-datetable.php?y=<?php echo $prevyear ?>&m=<?php echo $prevmonth ?>">上一月</a>|
<a href="new-datetable.php?y=<?php echo $nextyear ?>&m=<?php echo $nextmonth ?>">下一月</a>
</h3>
</center>
</body>
</html>
//当前年
$year=$_GET['y']?$_GET['y']:date('Y');
//当前月
$month=$_GET['m']?$_GET['m']:date('m');
//当前月1号的时间戳
$firstday=strtotime("{$year}-{$month}-1");
//当前月天数
$days=date('t',$firstday);
//当前月1号是周几
$week=date('w',$firstday);
// echo "$week";
// 上一年和上一月
$prevyear=$year;
$prevmonth=$month-1;
if($prevmonth<1){
$prevyear=$year - 1;
$prevmonth=12;
}
// 下一年和下一月
$nextyear=$year;
$nextmonth=$month+1;
if($nextmonth>12){
$nextyear=$year + 1;
$nextmonth=1;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
font-family:微软雅黑;
}
a{
text-decoration:none;
color:#55f;
}
</style>
</head>
<body>
<center>
<h2>万年历-<?php echo $year ?>年<?php echo $month ?>月</h2>
<table border="1px" cellspacing="0" width="700px">
<thead>
<tr>
<th>周日</th>
<th>周一</th>
<th>周二</th>
<th>周三</th>
<th>周四</th>
<th>周五</th>
<th>周六</th>
</tr>
</thead>
<?php
for($i=(1-$week);$i<=$days;){
echo '<tr>';
for($j=0;$j<7;$j++,$i++){
if($i>$days || $i<1){
echo "<td> </td>";
}else{
echo "<td>{$i}</td>";
}
}
echo '</tr>';
}
?>
</table>
<h3>
<a href="new-datetable.php?y=<?php echo $prevyear ?>&m=<?php echo $prevmonth ?>">上一月</a>|
<a href="new-datetable.php?y=<?php echo $nextyear ?>&m=<?php echo $nextmonth ?>">下一月</a>
</h3>
</center>
</body>
</html>
阅读全文
0 0
- 用php写一个简单低配版的万年历
- 用C语言写的一个万年历
- 一个简单的万年历
- 用java做一个简单的万年历
- 用java写一个万年历
- PHP实现简单的万年历
- 自己用java写的一个swing版的万年历
- 自己写的C语言简单万年历
- 用c#写万年历(简单版)
- PHP实例二之简单的万年历
- PHP实现简单的万年历(实例)
- 用php写的一个超简单的webservice
- 用PHP+MySQL写了一个简单的留言板
- php写一个简单的通讯录
- php写一个简单的登录程序
- 老师写的万年历
- C语言写一个万年历
- 我的源代码(php实现的简单万年历)
- 注解开发SPringMVC
- LOWORD,HIWORD,LOBYTE,HIBYTE
- js动态添加元素为何 点击事件无效
- 2017.10.29第九周周总结
- laravel之seeder之操作(批量增,删,改)
- 用php写一个简单低配版的万年历
- Java中的选择循环结构
- java多线程实现抢红包
- JAVA代码用方法构造器来制造
- FreeMarker 快速入门
- 《木兰花令·拟古决绝词柬友》
- 【JZOJ5430】【NOIP2017提高A组集训10.27】图
- 机器学习—Bagging与随机森林算法详解
- java匿名内部类详解