jim.davidson Posted August 27, 2010 Share Posted August 27, 2010 I have a timestamp field in my mySQL table and need to check if it's 14 day or older. What's the best way to do this? Any help will be appreciated Link to comment https://forums.phpfreaks.com/topic/211889-calculating-a-timestamp/ Share on other sites More sharing options...
The Eagle Posted August 27, 2010 Share Posted August 27, 2010 Although I don't completely understand I've a brief idea of what you want to accomplish. $time = strtotime('$time'); $two_weeks_ago = strtotime('-2 week'); if( $time > $two_weeks_ago ) { echo ""; } else { echo ""; } Link to comment https://forums.phpfreaks.com/topic/211889-calculating-a-timestamp/#findComment-1104405 Share on other sites More sharing options...
AbraCadaver Posted August 27, 2010 Share Posted August 27, 2010 Depends on what you mean by "check". Do you want to select records that are 14 days or older or not select records that are 14 days or older? This will do those: Older than 14 days: SELECT * FROM table_name WHERE ( TO_DAYS(CURDATE()) - TO_DAYS(column_name) ) > 14 Not older than 14 days: SELECT * FROM table_name WHERE ( TO_DAYS(CURDATE()) - TO_DAYS(column_name) ) <= 14 Link to comment https://forums.phpfreaks.com/topic/211889-calculating-a-timestamp/#findComment-1104407 Share on other sites More sharing options...
jim.davidson Posted August 27, 2010 Author Share Posted August 27, 2010 Thank you, now that I see it it seems simple enough even for me. Again Thanks Link to comment https://forums.phpfreaks.com/topic/211889-calculating-a-timestamp/#findComment-1104408 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.