Using Date.parse(), you can create a date object from a string and then calculate the difference in minutes.
Here's an example:
const startTime= Date.parse('2020-03-02 06:49:05')
const endTime = Date.parse('2020-03-02 07:05:02')
// Difference in Minutes
const durationInMin= (endTime-startTime)/60000;
console.log({ startTime, endTime, durationInMin })
alert(`Process took: ${durationInMin} minutes`)
If you need human-readable dates, consider using date-fns, which is lightweight compared to momentjs.
import { differenceInMinutes } from 'date-fns';
const startDate = '2020-03-02 06:49:05';
const endDate = '2020-03-02 07:05:02';
const durationInMin = differenceInMinutes(new Date(endDate), new Date(startDate));
console.log(`Duration: ${durationInMin} minutes`);
Adding another dependency may increase project size, but if you deal with many human-readable dates, it could be beneficial.