如果当前日期在页面之后,请删除页面


If current date is after page remove page?

我想知道是否有一种方法可以让你使用PHP根据日期删除内容?我有一个列出日期范围内事件的页面,我希望它删除已通过的事件。

I.e. 
If start date is before current date = remove event
If start date is after current date = keep event 
If start date is equal to current date = highlight event. 

您从哪里获得这些事件?是来自数据库的吗。并且是存储在数据库中的开始日期。

如果这在数据库中,那么您必须根据保存在数据库中的格式用php编写代码。

您可以使用php-date()函数来完成

您可以简单地添加一些SQL,删除(或归档)日期已过的事件。我想这些信息在数据库中。

或者,您可以简单地使用if语句,因此如果开始日期<不显示当前日期。

如果您使用的是数据库,只需选择将来发生的事件。

也许有一些逻辑,比如:

//psudeocode
    //you could also use a foreach() if you are working with an array()
    //start date greater then or equal to current date
    if ($start_date >= $cur_date){
         //do some stuf with the events
            if ($start_date == $cur_date) {
                //add hilighting
        }
    //else sart date is less then current date unset/delete/toss out
    } else {
        unset $event['old event'];
    }