Jump to content

timestamp compare


jagguy

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.