Hi Friends đź‘‹,
Welcome To Infinitbility! ❤️
To get minutes between two dates,
- Get both dates as a time using the
getTime()
method. - subtract them which you get using the
getTime()
method. - Devied your output time with
/ (1000 * 60) % 60
It will return your difference in dates in a minutes.
The getTime() method returns the number of milliseconds since the ECMAScript epoch.
You can use this method to help assign a date and time to another Date object. This method is functionally equivalent to the valueOf() method.
Today, I’m going to show How do I get minutes between two dates in javascript, here I will use the javascript getTime()
method and the above-mentioned conditions to get minutes between the start and end date time.
Let’s start the today’s tutorial How do you get minutes between two dates in javascript?
In the following example, we are going to do
- create two dates starting and ending date
- create a function that accepts a date and return minutes
- Use a function for multiple date examples
let’s write the code.
1function getMinutes(startingDate, endingDate) {2 return parseInt(((Math.abs(endingDate.getTime() - startingDate.getTime()) / 1000) / 60) % 60);3}45const startDate = new Date("2021-08-25 07:41:07");6const endDate = new Date("2021-08-25 07:50:07");78getMinutes(startDate, endDate); // âś… true
In the above program, we have created a custom function getMinutes()
and pass dates to get a mumber of minutes.
let’s check the output.

I hope it’s help you, All the best 👍.
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.