Click here to Skip to main content
15,904,339 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

How to find the minutes from two Datetime for the following scenerio.

Date1: 2015-12-31 21:00:00
Date2: 2016-01-01 05:00:00

Kindly provide your valuable feedback.

Thanks,
Sivasankaran G
Posted
Updated 13-Jan-16 3:13am
v3
Comments
Sri Nivas (Vasu) 14-Jan-16 1:16am    
Do you want to find minutes part of the each date ?

This is the kind of question that is very easily googled for and can save you time and will also help you learn more.

Essentially convert both to dates and then subtract them.

JavaScript
var Date1 = new Date(2015, 12, 31);
var Date2 = new Date(2016, 01, 01);
alert(Date2 - Date1);


See datetime - Difference between dates in JavaScript - Stack Overflow[^] for more examples.

Also refer to JavaScript Dates[^] for a good resource on dates.
 
Share this answer
 
Comments
Gssankar 13-Jan-16 9:08am    
Hi Ryan,

Thanks for your response. it includes time also
i.e
Date1: 2015-12-31 20:00:00
Date2: 2016-01-01 06:00:00
ZurdoDev 13-Jan-16 9:12am    
Not a problem.

1. You should have posted that in your original question.
2. Refer to the second link to see what the constructor looks like. This is easier than you think. You just need to do a little bit of reading.
Sergey Alexandrovich Kryukov 13-Jan-16 10:47am    
5ed.
—SA
ZurdoDev 13-Jan-16 10:54am    
Thank you.
If you want to find minutes part of the day you can find like below

//var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
var d = new Date(2014, 5, 22, 09, 45, 11, 23);

d.getMinutes();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900