Calculate time until button click

Hi everyone. I want to measure the time from the user login to the page until user clicks the submit button. For this, I set startTime variable as initial value {{ Date.now() }}. then I defined var elapsedTime = (endTime - startTime / 1000) on button's event handler. But always returning NaN , even though I tried different things, it didn't work. Can you help me?

I had some success like this:


Unsure where you're getting NaN, might be easier if you upload images of your implementation. I'm guessing that you're not reading your startTime properly; you need to get startTime.value since temporary state variables are objects with multiple keys in them, not only the value.

It works! Thank you so much.

1 Like