var today = new Date();
var Christmas = new Date("2012-12-25");
var diffMs = (Christmas - today); // milliseconds between now & Christmas
var diffDays = Math.floor(diffMs / 86400000); // days
var diffHrs = Math.floor((diffMs % 86400000) / 3600000); // hours
var diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // minutes
alert(diffDays + " days, " + diffHrs + " hours, " + diffMins + " minutes until Christmas 2009 =)");
Run code snippet
var startTime = new Date('2012/10/09 12:00');
var endTime = new Date('2013/10/09 12:00');
var difference = endTime.getTime() - startTime.getTime(); // This will give difference in milliseconds
var resultInMinutes = Math.round(difference / 60000);
// 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
//start timer
console.time();
//your code
//example:
let a = 1000 / 90;
let b = a%(100/90*198) ^ 89 >> 1 << 2;
//stop timer
var timeTakenForCodeToRun = console.timeEnd();