1//get Date diff as intervals
2$d1 = new DateTime("2018-01-10 00:00:00");
3$d2 = new DateTime("2019-05-18 01:23:45");
4$interval = $d1->diff($d2);
5$diffInSeconds = $interval->s; //45
6$diffInMinutes = $interval->i; //23
7$diffInHours = $interval->h; //8
8$diffInDays = $interval->d; //21
9$diffInMonths = $interval->m; //4
10$diffInYears = $interval->y; //1
11
12//or get Date difference as total difference
13$d1 = strtotime("2018-01-10 00:00:00");
14$d2 = strtotime("2019-05-18 01:23:45");
15$totalSecondsDiff = abs($d1-$d2); //42600225
16$totalMinutesDiff = $totalSecondsDiff/60; //710003.75
17$totalHoursDiff = $totalSecondsDiff/60/60;//11833.39
18$totalDaysDiff = $totalSecondsDiff/60/60/24; //493.05
19$totalMonthsDiff = $totalSecondsDiff/60/60/24/30; //16.43
20$totalYearsDiff = $totalSecondsDiff/60/60/24/365; //1.35
1$time1 = new DateTime('09:00:59');
2$time2 = new DateTime('09:01:00');
3$interval = $time1->diff($time2);
4echo $interval->format('%s second(s)');
5
6Result: 1 second(s)
1First, make those minutes into seconds:
2
34 min 35 sec = 275 seconds
4
511 min = 660 seconds
6
7Your percentage of remaining time will be (275 / 660) * 100. The percentage of time left would be ((660 - 275) / 660) * 100. Of course, that's all in seconds. Don't know how you are receiving that time in php, but it might look like:
8
9$maxTime = 660;
10$timeTaken = 275;
11
12$percentage = ($timeTaken / $maxTime) * 100;
13
14// To get percentage of time left
15$percentLeft = (($maxTime - $timeTaken) / $maxTime) * 100;