I have looked at this question but time format is different
I have following date format Tue, 11 Sep 2012 17:38:09 GMT
in $pubDate
variable
I would like to compare $pubDate
with current Date and Time to see if Tue, 11 Sep 2012 17:38:09 GMT
is in last 10 mins or not
EDIT:
I have tried
//get current time
strtotime($pubDate);
time() - strtotime($pubDate);
if((time()-(60*10)) < strtotime($pubDate)){
//if true increase badge by one
$badge = $badge + 1;
}
it gives the warning: It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /Users/xxxxx/Desktop/xxxx/xxxx/xxxx.php on line 26
EDIT:
I have added date_default_timezone_set('America/New_York');
line to my php and now
$inDate = DateTime::createFromFormat( $format, $pubDate);
$postDate = new DateTime();
$diff = $inDate->diff( $postDate);
// If the total number of days is > 0, or the number of hours > 0, or the number of minutes > 10, then its an invalid timestamp.
if( $diff->format( '%a') > 0 || $diff->format( '%h') > 0 || $diff->format( '%i') > 10) {
die( 'The timestamps differ by more than 10 minutes');
}
works without warning, Thanks everyone