donglei2022 2018-07-18 14:25
浏览 86

除了过去24小时的UNIX时间格式外,如何从数据库中删除数据

I want to delete data from database via corn.

For example: i need to delete my all data except last 24 hour.

My time format is UNIX time Like

1531920800

  • 写回答

2条回答 默认 最新

  • dongyuan2652 2018-07-18 14:28
    关注

    This should do the trick:

    $time = time();
    $oneDay = 60 * 60 * 24;
    $yesterday = $time - $oneDay;
    
    $sql = 'DELETE FROM tablename WHERE columname < ' . $yesterday;
    
    评论

报告相同问题?