Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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.
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to clear nodemon cache 
Javascript :: javascript add required attribute to input 
Javascript :: randomly genaret color in js 
Javascript :: confirm delete message in jquery 
Javascript :: calculate age based on date of birth in javascript 
Javascript :: bootstrap modal show jquery 
Javascript :: if string has number javascript 
Javascript :: js waiting element exist 
Javascript :: open link in new window chrome mac shortcut 
Javascript :: jstl replace 
Javascript :: Masonry js cdn 
Javascript :: string check javascript 
Javascript :: auto reload page javascript 
Javascript :: post antiforgerytoken jquery 
Javascript :: how to call await outside async function in js 
Javascript :: javascript sort array of objects by date 
Javascript :: js string replaceall 
Javascript :: window.location.href target blank 
Javascript :: generate random base 64 string js 
Javascript :: javascript convert number to hex 
Javascript :: javascript get domain name from string 
Javascript :: jquery scroll to id 
Javascript :: javascript group by on array of objects 
Javascript :: javascript button go to url 
Javascript :: create array number javascript 
Javascript :: js get paste text 
Javascript :: mac install jmeter 
Javascript :: python json to excel converter 
Javascript :: vh not working on phone 
Javascript :: how to copy text in react 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =