Select rows from MySQL table where PHP timestamp is older than X

前端 未结 4 539
逝去的感伤
逝去的感伤 2020-12-17 02:12

I have a user table, where users need to be approved, i want to show users who are not approved and is registered more than 7 days ago.

My user_regdate is a timestam

4条回答
  •  情歌与酒
    2020-12-17 02:46

    PHP's timstamps are a simple integer, whereas MySQL's now() returns a datetime value. Most likely this will fix up the query:

    SELECT ... WHERE user_regdate < unix_timestamp(now() - interval 7 day)) ...
    

    Basically, without the unix_timstamp() call, you're comparing apples and oranges.

提交回复
热议问题