jagguy Posted July 15, 2007 Share Posted July 15, 2007 I want to compare a timestamp value from mysql and if it is more than 2 days old then delete. Hoq do i compare 2 timestamps with php? Link to comment https://forums.phpfreaks.com/topic/60040-timestamp-compare/ Share on other sites More sharing options...
infid3l Posted July 15, 2007 Share Posted July 15, 2007 I want to compare a timestamp value from mysql and if it is more than 2 days old then delete. Hoq do i compare 2 timestamps with php? Unix timestamps? <?php if (($timestamp1 - $timestamp2) >= 172800) { // older than 2 days } ?> Otherwise: <?php if ((strtotime($timestamp1) - strtotime($timestamp2)) >= 172800) { // older than 2 days } ?> $timestamp1 being the larger value, of course. Link to comment https://forums.phpfreaks.com/topic/60040-timestamp-compare/#findComment-298644 Share on other sites More sharing options...
Panjabel Posted July 15, 2007 Share Posted July 15, 2007 Thanks What about this: <?php if (($timestamp1 - $timestamp2) >= strtotime("-2 day")) { // older than 2 days } ?> Link to comment https://forums.phpfreaks.com/topic/60040-timestamp-compare/#findComment-298655 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.