note 96247 deleted from function.strtotime by derick

From: Date: Sun, 14 Dec 2014 11:41:11 +0000
Subject: note 96247 deleted from function.strtotime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-201178@lists.php.net to get a copy of this message
Note Submitter: octavio ---- This function calculates if date2 is within an interval of seconds from date1. <?php function is_on_interval($date1,$date2,$interval){ $dat2=strtotime($date2); $dat3=strtotime('+'.$interval.' second '.$date1); if($dat2>=$dat3){ return false; } else { return true; } } $date1='2009-08-18 00:02:00'; $date2='2009-08-18 00:05:00'; ?> $date2 is 180 seconds from $date1. <?php is_on_interval($date1,$date2,'120'); ?> will return false. <?php is_on_interval($date1,$date2,'180'); ?> will return true. <?php is_on_interval($date1,$date2,'220'); ?> will return true.

« previous php.notes (#201178) next »