Skip to content
Advertisement

How to time duration calculate in react js

I want to calculate the time duration with the current time and another time. In my problem the current time and all ready time in data base time format are different, this format is given format: 2020-11-07 , 22:52
but now time format is 30/10/2020 , 20:50:34 . So I have a problem with this diffrent format.

Advertisement

Answer

You can convert both values to timestamps (in milliseconds) from their own formats and then calculate the difference in milliseconds with simple math.

If you are having trouble parsing the values, you can check Date documentation. An example can be:

let birthday = new Date('1995-12-17T03:24:00')
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement