php时间判断

WBOY
Release: 2016-06-23 13:56:40
Original
1011 people have browsed it

想在某个时间段,例如:2014/5/21-2014/5/31显示“高级会员”日期超过2014/5/31则显示“会员已过期”,应该怎么做?


回复讨论(解决方案)

你指的时间是怎么来的呢?用户注册时间(数据库,格式是怎么样的)?当前时间?

你指的时间是怎么来的呢?用户注册时间(数据库,格式是怎么样的)?当前时间?



手动指定,或者用天数计算,如:2014/5/21  7天后过期,这样

<?phpif(time()>=strtotime('2014-5-21') && time()<=strtotime('2014-5-31')){    echo '高级会员';}else{    echo '会员已过期';}?>
Copy after login

关键字:时间戳加减

直接数据库查询,设定的过期时间是否在规定时间段内,不在就过期。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!