Answers for "fine diffrencr between two time in js"

3

javascript get seconds between two dates

var secondBetweenTwoDate = Math.abs((new Date().getTime() - oldDate.getTime()) / 1000);
Posted by: Guest on January-30-2020
-1

javascript time difference

// use new Date to specify the dates
var myDate = new Date(/*YOUR DATE VALUES, STRING or NUMBER PARAMETERS*/); 

// example
var date1 = new Date("2010-9-16 13:30:58"); // Thu Sep 16 2010 13:30:58
var date2 = new Date(2015, 7, 18, 14, 20, 48); // Tue Aug 18 2015 14:20:48

// checking with date is more recent to get the other out of it and store the result in dateDifference variable
var dateDifference;
if (date2 < date1) {
    dateDifference = date2 - date1;
}
else{
    dateDifference = date1 - date2;
}

console.log(dateDifference); // the result will be in milliseconds
Posted by: Guest on June-14-2021

Code answers related to "fine diffrencr between two time in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language