Vivid Lust Posted March 9, 2011 Share Posted March 9, 2011 How can I check in php if a timestamp was x days ago For example the timestamp 1287677304 , how can I check if it was more than 2 days ago? Thanks lots Jake Quote Link to comment https://forums.phpfreaks.com/topic/230085-checking-if-timestamp-was-x-days-ago/ Share on other sites More sharing options...
bh Posted March 9, 2011 Share Posted March 9, 2011 Hi, strtotime("-5 day") gives you in timestamp the date that was 5 days ago Update: as mktime(0, 0, 0, date('m'), date('d')-5, date('Y')) Quote Link to comment https://forums.phpfreaks.com/topic/230085-checking-if-timestamp-was-x-days-ago/#findComment-1184948 Share on other sites More sharing options...
Vivid Lust Posted March 9, 2011 Author Share Posted March 9, 2011 so then after i can just do if 1287677304 > 1287675673 ???? Quote Link to comment https://forums.phpfreaks.com/topic/230085-checking-if-timestamp-was-x-days-ago/#findComment-1184949 Share on other sites More sharing options...
bh Posted March 9, 2011 Share Posted March 9, 2011 Yap Quote Link to comment https://forums.phpfreaks.com/topic/230085-checking-if-timestamp-was-x-days-ago/#findComment-1184951 Share on other sites More sharing options...
litebearer Posted March 9, 2011 Share Posted March 9, 2011 rough idea if ((current ts - old ts)/86400) >= x Grrrrr slow typist here Quote Link to comment https://forums.phpfreaks.com/topic/230085-checking-if-timestamp-was-x-days-ago/#findComment-1184953 Share on other sites More sharing options...
bh Posted March 9, 2011 Share Posted March 9, 2011 if (strtotime("-5 day") >= $a_timestamp) { // it was 5 or more days ago } Quote Link to comment https://forums.phpfreaks.com/topic/230085-checking-if-timestamp-was-x-days-ago/#findComment-1184955 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.