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.
var t1 = new Date("2021-08-25 07:41:07"); var t2 = new Date("2021-08-25 07:50:07"); var dif = ( t2.getTime() - t1.getTime() ) / 1000; console.log(dif)
Thanks for reading…