1//start timer
2console.time();
3//your code
4//example:
5let a = 1000 / 90;
6let b = a%(100/90*198) ^ 89 >> 1 << 2;
7//stop timer
8var timeTakenForCodeToRun = console.timeEnd();
1var today = new Date();
2var Christmas = new Date("2012-12-25");
3var diffMs = (Christmas - today); // milliseconds between now & Christmas
4var diffDays = Math.floor(diffMs / 86400000); // days
5var diffHrs = Math.floor((diffMs % 86400000) / 3600000); // hours
6var diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // minutes
7alert(diffDays + " days, " + diffHrs + " hours, " + diffMins + " minutes until Christmas 2009 =)");
8 Run code snippet
1// use new Date to specify the dates
2var myDate = new Date(/*YOUR DATE VALUES, STRING or NUMBER PARAMETERS*/);
3
4// example
5var date1 = new Date("2010-9-16 13:30:58"); // Thu Sep 16 2010 13:30:58
6var date2 = new Date(2015, 7, 18, 14, 20, 48); // Tue Aug 18 2015 14:20:48
7
8// checking with date is more recent to get the other out of it and store the result in dateDifference variable
9var dateDifference;
10if (date2 < date1) {
11 dateDifference = date2 - date1;
12}
13else{
14 dateDifference = date1 - date2;
15}
16
17console.log(dateDifference); // the result will be in milliseconds