Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

timestamp check if 10 minutes ago

Tags:

date

php

I have a data in a text file saved using date("Y-m-d h:i:s", strtotime("+2 minutes")) that I need to check if it's 10 minutes ago. I'm trying the following code but it doesn't print anything even if more than 10 minutes ago.

  $now = date("Y-m-d h:i:s", strtotime("now"));
  if($now > strtotime($old_data))
       echo 'expired!';
like image 788
Jack Avatar asked Jun 27 '14 01:06

Jack


1 Answers

your comparing a formatted date with a time stamp which explains why nothing works

here:

$now = strtotime("-10 minutes");

if ($now > strtotime($old_data) {
  echo 'expired!';
}
like image 75
devBorg Avatar answered Oct 08 '22 21:10

devBorg