0

I need to check if that given date is less than 24 hours from current date.

$custom="2014-10-10T20:59:11.000Z";
$createDate = new DateTime($custom); 
$now = new DateTime();
$difference = $now->diff($createDate, true);

Now I get $difference->d and $difference->h.

How to find the difference in hours?

Bud Damyanov
  • 27,507
  • 6
  • 41
  • 51
Anisha Gowda
  • 59
  • 1
  • 6

1 Answers1

-1

Get the hour of this difference using DateTime::format(string $format) :

$hourGap = $difference->format("h");
Anwar
  • 3,898
  • 4
  • 37
  • 60