Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $year1 = mt_rand(2000, 2020);
- $month1 = mt_rand(1, 12);
- $days1 = mt_rand(1, 31);
- $hours1 = mt_rand(1, 24);
- $minutes1 = mt_rand(1, 59);
- $seconds1 = mt_rand(1, 59);
- $date_1 = new DateTime("$year1-$month1-$days1 $hours1:$minutes1:$seconds1");
- echo $date_1->format('d.m.Y H:i:s') . '<br>';
- $year2 = mt_rand(2000, 2020);
- $month2 = mt_rand(1, 12);
- $days2 = mt_rand(1, 31);
- $hours2 = mt_rand(1, 24);
- $minutes2 = mt_rand(1, 59);
- $seconds2 = mt_rand(1, 59);
- $date_2 = new DateTime("$year2-$month2-$days2 $hours2:$minutes2:$seconds2");
- echo $date_2->format('d.m.Y H:i:s') . '<br>';
- $difference = $date_1->diff($date_2);
- echo $difference->format('d.m.Y H:i:s');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement