0
  $dday = mktime(13, 00,00, 02, 07, 2013);

  $today = mktime(12,30,00, 02, 08, 2018);

  $difference = $today - $dday;

  $DateCalculation = floor($difference / 84600);

echo $DateCalculation;

The day is 1. But actually its not 1. The day will be 1 only when the time is 13.00.Can anyone answer me please?

John Conde
  • 217,595
  • 99
  • 455
  • 496

2 Answers2

2

The DateTime class makes working with dates and times much easier them mktime()

$datetime1 = new DateTime('2013-02-07 13:00:00');
$datetime2 = new DateTime('2013-02-08 12:30:00');
$interval = $datetime1->diff($datetime2);
$elapsed = $interval->format('%a days %h hours');

echo $elapsed . PHP_EOL;
echo "Days: " . $interval->format('%a') . PHP_EOL;

// Output
0 days 23 hours
Days: 0

See it in action

John Conde
  • 217,595
  • 99
  • 455
  • 496
0

u may look for this

 $dday = ('13, 00,00, 02, 07, 2013');
 $sub = substr($dday, 14,-6);

 $today = ('12,30,00, 02, 08, 2018');
 $sub_today = substr($today, 14,-6);

 $difference = $sub_today - $sub ;

 echo $difference .' day';  // -- will output: 1 day
echo_Me
  • 37,078
  • 5
  • 58
  • 78