查看: 715|回复: 1
|
php的找日期差别的问题
[复制链接]
|
|
以下是我的源码
<?
$duedate="05-03-2007";
$date=split("-",$duedate);
$todaydate=date("d-m-Y");
$firstreminder=date("d-m-Y",mktime(0,0,0,$date[1],$date[0]+7,$date[2]));
$secondreminder=date("d-m-Y",mktime(0,0,0,$date[1]+1,$date[0]+7,$date[2]));
$finalnotice=date("d-m-Y",mktime(0,0,0,$date[1]+1,$date[0]+14,$date[2]));
$forthsche=date("d-m-Y",mktime(0,0,0,$date[1]+1,$date[0]+21,$date[2]));
echo "<table>";
echo "<tr><td>Date name</td><td>Date</td><td>Strtotime</td></tr>";
echo "<tr><td>Duedate</td><td>".$duedate." </td><td> ". strtotime($duedate)."</td></tr>";
echo "<tr><td>Today</td><td>".$todaydate." </td><td> ". strtotime($todaydate)."</td></tr>";
echo "<tr><td>Firstreminder</td><td>". $firstreminder." </td><td> ". strtotime($firstreminder)."</td></tr>";
echo "<tr><td>Secondreminder</td><td>".$secondreminder." </td><td> ". strtotime($secondreminder)."</td></tr>";
echo "<tr><td>Finalnotice</td><td>".$finalnotice." </td><td> ". strtotime($finalnotice)."</td></tr>";
echo "<tr><td>Forthsche</td><td>".$forthsche." </td><td> ". strtotime($forthsche)."</td></tr>";
if(strtotime($todaydate)>strtotime($firstreminder) && strtotime($todaydate)<strtotime($secondreminder))
{
echo"<tr><td>Status</td><td>First reminder</td></tr>";
}
elseif(strtotime($todaydate)>strtotime($secondreminder) && strtotime($todaydate)<strtotime($finalnotice))
{
echo"<tr><td>Status</td><td>Second reminder</td></tr>";
}
elseif(strtotime($todaydate)>strtotime($finalnotice) && strtotime($todaydate)<strtotime($forthsche))
{
echo"<tr><td>Status</td><td>final notice</td></tr>";
}
elseif(strtotime($todaydate)>strtotime($forthsche))
{
echo"<tr><td>Status</td><td>forth schedule</td></tr>";
}
else
{
echo"<tr><td>Status</td><td>Not yet expired</td></tr>";
} |
|
|
|
|
|
|
|

楼主 |
发表于 15-2-2007 05:17 PM
|
显示全部楼层
这是OUTPUT...
Date name | Date | Strtotime | Duedate | 05-03-2007 | 1282978800 | Today | 14-02-2007 | 1564556400 | Firstreminder | 12-03-2007 | 1503903600 | Secondreminder | 12-04-2007 | 1506582000 | Finalnotice | 19-04-2007 | 1727420400 | Forthsche | 26-04-2007 | 1948345200 | Status | Second reminder | |
为什么strtotime的数目不会随着日期增加的?比如12-03-2007的unixtimestamp应该会小过14-02-2007的。。如果我要用这样的日期格式来找日期和日期的分别,请问要如何呢??
新年快乐~~ |
|
|
|
|
|
|
| |
本周最热论坛帖子
|