Click here to Skip to main content
15,887,083 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: JavaScript, not even once Pin
Sander Rossel10-Nov-20 23:50
professionalSander Rossel10-Nov-20 23:50 
GeneralRe: JavaScript, not even once Pin
Kornfeld Eliyahu Peter11-Nov-20 0:00
professionalKornfeld Eliyahu Peter11-Nov-20 0:00 
GeneralRe: JavaScript, not even once Pin
Richard Deeming11-Nov-20 0:42
mveRichard Deeming11-Nov-20 0:42 
GeneralRe: JavaScript, not even once Pin
Kornfeld Eliyahu Peter11-Nov-20 1:04
professionalKornfeld Eliyahu Peter11-Nov-20 1:04 
GeneralRe: JavaScript, not even once Pin
Sander Rossel11-Nov-20 4:16
professionalSander Rossel11-Nov-20 4:16 
GeneralRe: JavaScript, not even once Pin
theoldfool11-Nov-20 1:40
professionaltheoldfool11-Nov-20 1:40 
GeneralRe: JavaScript, not even once Pin
BillWoodruff11-Nov-20 2:08
professionalBillWoodruff11-Nov-20 2:08 
GeneralRe: JavaScript, not even once Pin
raddevus11-Nov-20 2:41
mvaraddevus11-Nov-20 2:41 
1) Press F12 (while viewing this page)
2) copy the code below
3) paste it into the console and run it

JavaScript
let startTime = Date.now();
setTimeout(()=>{
  let endTime= Date.now();
  let timeSpent=(endTime-startTime)/1000+" seconds.";
  alert("It took " + timeSpent + " to complete");
},Math.floor((Math.random() * 8000)));


It'll set a timeout that will last between 0 and 8 seconds.
When the timeout fires, it will calc times between startTime and endTime (in seconds) and display the value in an alert.

Does calculating the time between those two times not work?
It's an interesting coincidence because I just used the time measuring code in some JS I wrote yesterday.
There is also the new(er)
JavaScript
window.performance.now()


Update
Just noticed that it sounds like you are saying you "have a start and end time"...maybe as a string. that's a lot more difficult. Smile | :)
GeneralRe: JavaScript, not even once Pin
Sander Rossel11-Nov-20 3:27
professionalSander Rossel11-Nov-20 3:27 
GeneralRe: JavaScript, not even once Pin
raddevus11-Nov-20 3:44
mvaraddevus11-Nov-20 3:44 
GeneralRe: JavaScript, not even once Pin
honey the codewitch11-Nov-20 3:59
mvahoney the codewitch11-Nov-20 3:59 
GeneralRe: JavaScript, not even once Pin
Sander Rossel11-Nov-20 4:05
professionalSander Rossel11-Nov-20 4:05 
GeneralRe: JavaScript, not even once Pin
honey the codewitch11-Nov-20 4:08
mvahoney the codewitch11-Nov-20 4:08 
GeneralRe: JavaScript, not even once Pin
Marc Clifton11-Nov-20 6:52
mvaMarc Clifton11-Nov-20 6:52 
GeneralRe: JavaScript, not even once Pin
Sander Rossel11-Nov-20 9:16
professionalSander Rossel11-Nov-20 9:16 
GeneralRe: JavaScript, not even once Pin
Jörgen Andersson22-Nov-20 21:51
professionalJörgen Andersson22-Nov-20 21:51 
GeneralRe: JavaScript, not even once Pin
Sander Rossel22-Nov-20 21:54
professionalSander Rossel22-Nov-20 21:54 
GeneralWSO CCC OTD 2020-11-11 Pin
OriginalGriff10-Nov-20 22:01
mveOriginalGriff10-Nov-20 22:01 
GeneralRe: WSO CCC OTD 2020-11-11 Pin
pkfox10-Nov-20 22:52
professionalpkfox10-Nov-20 22:52 
GeneralRe: WSO CCC OTD 2020-11-11 Pin
yacCarsten10-Nov-20 22:54
yacCarsten10-Nov-20 22:54 
GeneralRe: WSO CCC OTD 2020-11-11 - we have a winner! Pin
OriginalGriff10-Nov-20 23:02
mveOriginalGriff10-Nov-20 23:02 
GeneralRe: WSO CCC OTD 2020-11-11 - we have a winner! Pin
Kornfeld Eliyahu Peter10-Nov-20 23:13
professionalKornfeld Eliyahu Peter10-Nov-20 23:13 
GeneralRe: WSO CCC OTD 2020-11-11 - we have a winner! Pin
OriginalGriff10-Nov-20 23:21
mveOriginalGriff10-Nov-20 23:21 
NewsIt is now cool (and expensive) to drink and drive Pin
megaadam10-Nov-20 20:12
professionalmegaadam10-Nov-20 20:12 
GeneralRe: It is now cool (and expensive) to drink and drive Pin
Rage10-Nov-20 20:29
professionalRage10-Nov-20 20:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.