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? Quote Link to comment 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. Quote Link to comment 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 } ?> Quote Link to comment 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.