Hello Friends 👋,
Welcome To Infinitbility! ❤️
Manytimes for analytics we have to calculate time difference between user start using feature and user end using feature.
We have to both date object and using
getTime() function take both date time and subtract time2 to time 1.
In below example, First we create two objects and store in variable and when we substract dates and divide by 1000 then we will get difference in seconds.
1var t1 = new Date("2021-08-25 07:41:07");2var t2 = new Date("2021-08-25 07:50:07");3var dif = ( t2.getTime() - t1.getTime() ) / 1000;4console.log(dif)
Thanks for reading…
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.