Advertisement
myphp

Untitled

Jul 12th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1.     $year1 = mt_rand(2000, 2020);
  2.     $month1 = mt_rand(1, 12);
  3.     $days1 = mt_rand(1, 31);
  4.     $hours1 = mt_rand(1, 24);
  5.     $minutes1 = mt_rand(1, 59);
  6.     $seconds1 = mt_rand(1, 59);
  7.     $date_1 = new DateTime("$year1-$month1-$days1 $hours1:$minutes1:$seconds1");
  8.     echo $date_1->format('d.m.Y H:i:s') . '<br>';
  9.    
  10.     $year2 = mt_rand(2000, 2020);
  11.     $month2 = mt_rand(1, 12);
  12.     $days2 = mt_rand(1, 31);
  13.     $hours2 = mt_rand(1, 24);
  14.     $minutes2 = mt_rand(1, 59);
  15.     $seconds2 = mt_rand(1, 59);
  16.     $date_2 = new DateTime("$year2-$month2-$days2 $hours2:$minutes2:$seconds2");
  17.     echo $date_2->format('d.m.Y H:i:s') . '<br>';
  18.    
  19.     $difference = $date_1->diff($date_2);
  20.     echo $difference->format('d.m.Y H:i:s');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement