Answers for "get difference in hours between two dates"

5

javascript get hours difference between two dates

// date1 and date2 are date objects

let hours = Math.abs(date1 - date2) / 36e5;

// The subtraction returns the difference between the two dates in milliseconds.
// 36e5 is the scientific notation for 60*60*1000, dividing by which converts
// the milliseconds difference into hours.
Posted by: Guest on January-12-2021
0

Find difference between two dates in minutes

$time = new DateTime("2012-09-21 12:12:22");
$diff = $time->diff(new DateTime());
$minutes = ($diff->days * 24 * 60) +
           ($diff->h * 60) + $diff->i;
Posted by: Guest on May-26-2021

Code answers related to "get difference in hours between two dates"

Code answers related to "Javascript"

Browse Popular Code Answers by Language