Check if timestamp is x hours old?

前端 未结 2 452
轻奢々
轻奢々 2021-01-01 18:46

Simple question, but I couldn\'t find any related topics that match this exact scenario. Everything I found involved MySQL or date and time rather than just time.

I

2条回答
  •  旧巷少年郎
    2021-01-01 19:09

    Drop the first strtotime; the variable is already in timestamp form:

    if ($ratesTimeStamp <= strtotime('-2 hours')) {
        echo "OLDER";
    } else {
        echo "not older";
    }
    

提交回复
热议问题