我创建了一个获取文章发表时间的函数。相同的功能检查文章是否存在 1 周并停用它。
如果我必须在调用时使函数响应,我不知道该怎么做。我想到了使用 JavaScript 并为函数设置超时。那将是太多的循环。
这是我用来检查日期的“如果”。谁有更好的主意,请帮忙。
if((time() - $publish_time) > (7*24*60*60)){
// if the current timestamp - the time the article was published > 1 week.
//Execute the query to deactivate the article
}
该片段位于我必须调用的函数中。