Comparing timestamp to current time from database

前端 未结 4 1393
感情败类
感情败类 2020-12-29 03:50

I need to test current time against a datetime from database, if it has been 30 mins then execute code, if not then dont. This is where I am at and I am stuck:



        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 04:34

    SELECT id FROM dwCache ORDER BY id DESC LIMIT 1
    

    you'll get only id field, it's the first. The second, for time converting: MySQL convert datetime to Unix timestamp

    Third: you can convert your time string using strtotime function.

提交回复
热议问题