php - 检测会员时间到期PHP
问题描述
我正在尝试为一个月(2419200 秒)后在我的网站上购买会员资格的用户自动过期
但是,当我更改行的日期时,它似乎不起作用。我已经尝试将时间功能包装在不同的区域,甚至禁用它,我似乎遇到了它的工作问题。
buyDate 参数是我的 SQL 数据库中对象的一部分。(unix时间整数)任何帮助将不胜感激。
<?php
if(time($membershipExpire->buyDate) <= time($membershipExpire->buyDate + 2419200)){
die("Your membership has expired. Please contact someone to remove your membership in order to continue playing.");
}
?>
解决方案
重写它略有不同
<?php
$end = $membershipExpire->buyDate + 2419200;
if(time() >= $end)
{
die("Your membership has expired. Please contact someone to remove your membership in order to continue playing.");
}
?>
我还注意到当前时间必须大于结束时间,而在您的原始代码中,您使用的是小于号。
还有一件事与代码无关。您的错误消息显示“您的会员资格已过期。请联系某人删除您的会员资格以继续玩。”
不应该是“更新您的会员资格”吗?
推荐阅读
- python - 使用 geopandas 从 HDFS 读取 shapefile
- python - 当我不是频道的所有者时,telethon edit_admin 不起作用
- node.js - 如何让 Node.js 使用虚拟内存?
- c# - 如何在 c# 中将字符串转换为 LiteDb.ObjectId,反之亦然
- pandas - 如何循环遍历熊猫数据框以立即制作箱线图
- java - Spring Boot中使用HSQLDB时获取数据库锁失败
- python-3.x - 不同人的上次访问时间间隔
- sparql - 根据部分名称匹配检索 Wikidata ID 候选者
- mysql - Google CloudSQL 上的全局变量 explicit_defaults_for_timestamp
- python - 它如何将列表中的结果保存到 .txt 文件中?