分类信息有效期设置,如下图:
第一步:增加字段gqtime 类型选择日期。
<select name="gqtime" id="gqtime"><option value="<?echo date("Y-m-d",strtotime("+7day")); ?><?=DoReqValue($tbname,'gqtime',stripSlashes($r[gqtime]))?>">7天后过期</option><option value="<?echo date("Y-m-d",strtotime("+1month")); ?><?=DoReqValue($tbname,'gqtime',stripSlashes($r[gqtime]))?>">一个月后过期</option><option value="<?echo date("Y-m-d",strtotime("+3month")); ?><?=DoReqValue($tbname,'gqtime',stripSlashes($r[gqtime]))?>">三个月后过期</option><option value="<?echo date("Y-m-d",strtotime("+6month")); ?><?=DoReqValue($tbname,'gqtime',stripSlashes($r[gqtime]))?>" selected>六个月后过期</option><option value="<?echo date("Y-m-d",strtotime("+20year")); ?><?=DoReqValue($tbname,'gqtime',stripSlashes($r[gqtime]))?>">长期有效</option></select>
第二步:打开e/class/connect.php文件,找到 //栏目链接。在其上面一行加入如下代码:
//时间
$odate = round(((strtotime($r[gqtime])-strtotime(date('Y-m-d')))/86400),0);
if ($odate>0)
{
$diffTime = ''; //
}
else if ($odate==0)
{
$diffTime = '今天到期 ';
}
else
{
$diffTime = '<span class="expire">已过期</span> ';
}
$listtemp = str_replace ('[!--diffTime--]', $diffTime, $listtemp);
第三步:信息调用:
列表页调用:[!--diffTime--]
内容页引用JS:
<script language="javascript" src="images/date.js"></script>
在需要显示的地方调用:
<script>check_tdate('[!--gqtime--]')</script>
date.js 文件代码如下:
// JavaScript Document
function check_tdate(odate){
var checkArray= new Array() ;
//nowArray = odate.split(" ");
checkArray = odate.split("-");
checkDate = new Date(checkArray[0],checkArray[1],checkArray[2]);
var nowTime = new Date();// 现在时间
var the_year = nowTime.getYear();
var the_month = nowTime.getMonth() + 1;
var the_day = nowTime.getDate();
nowTime = new Date(the_year,the_month,the_day);
var thesecond = 24 * 60 * 60 *1000 ;
var diffTime = (nowTime - checkDate)/thesecond;//计算天数
if (diffTime>0)
{
myreturn ="<div style='position:absolute;z-index:100;margin-left:150px;'><img src=../../../images/guoqi.gif></div>";
}
else if (diffTime==0)
{
myreturn = '';
}
else
{
diffTime=0-diffTime;
myreturn = '';
}
//alert(myreturn);
document.write(''+myreturn+'')
}
已过期图片:
- 最新文章
-
- phpcms v9无法更新url
- phpcms注册会员操作失败
- phpcms怎么修改模板
- phpcms添加内容报500错误的原因及解决方法
- linux服务器下phpcms提示hash数据验证失败的解决方法
- phpcms与phpsso通信失败的解决方法
- phpcms上传图片提示服务器安全认证错误的原因及解决方法
- phpcms v9更新栏目缓存失败的原因及解决方法
- phpcms v9后台登录提示验证码错误
- phpcms可以做什么?
- phpcms v9安装失败
- phpcms会员登录失败
- phpcms前台js获取不到cookie用户信息
- phpcms控制器不存在
- phpcms v9 php7可以运行吗
- phpcms js乱码怎么解决
- phpcms提示服务器安全认证错误
- phpcms php.ini在哪里
- phpcms phpsso验证码错误
- phpcms v9参数传递错误
- 热门文章
- 热门tag
- 随机tag