Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我开发了广告网站
但我有问题,我想从注册日期开始
当这段时间结束时,广告将消失
我输入了插入查询
例子:
//i put in insert query for reg_date this 'insert into ads (reg_date) values (NOW());
第 1 行 --- reg_date ==== 13/11/2012 row2 --- exp_date ==== 1 个月
我希望一个月后这个广告会消失或不活跃
INSERT INTO ads (reg_date, exp_date) VALUES (now(), DATE_ADD(NOW(), INTERVAL 1 MONTH))
编写一个 cron 文件,让 exp_date 在期末前 7 天发出警报,并安排此 cron 每天运行。查询以获取 7 天之前的到期日期如下。
SELECT * FROM ads WHERE DATE_ADD(CURDATE(),INTERVAL 7 DAY) = exp_date;