You can get the duration between the start and end time in minutes by calculating the difference between two dates in milliseconds and then converting it into minutes.
Here's an example:
index.tsx213 chars7 lines
In the example above, we first create two Date
objects representing the start and end time. We then calculate the duration between the two times by subtracting the start time from the end time, and dividing the result by the number of milliseconds in a minute. Finally, we log the duration in minutes to the console.
Note that the getTime()
method returns the number of milliseconds since January 1, 1970, 00:00:00 UTC, so we divide the result by the number of milliseconds in a minute (1000 * 60) to get the duration in minutes.
gistlibby LogSnag