Got this working on php 5.3
$datetime1 = new DateTime("2011-10-10 10:00:00");
$datetime2 = new DateTime("2011-10-10 10:45:00");
$interval = $datetime1->diff($datetime2);
$hours = $interval->format('%h');
$minutes = $interval->format('%i');
echo 'Diff. in minutes is: '.($hours * 60 + $minutes);
How can i make it work on php 5.2 ? are there any equivalent functions available??
Got it working
$date1 = "2011-10-10 10:00:00";
$date2 = "2011-10-10 10:11:00";
echo round((strtotime($date2) - strtotime($date1)) /60);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…