Hours difference between 2 dates

Dear All,

I have this variable.

var myTodayDate = new Date();
var myDueDate='2010-11-31'

I want to know how many hours will be for : myDueDate - myTodayDate.

Please advise. Thanks      
Who is Participating?

Improve company productivity with a Business Account.Sign Up

for_yanConnect With a Mentor Commented:
There is probably some methd with Calendar
but the simple thig f=would be:

double hours = (double)(d1.getTime()-d2.getTime())/(60L*60L*1000L)
But I guess you have it in JavaScript ?
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Actually date.getTime() should also work in JavaScript as milliseconds since 1970
only you don't have these long numbers,
probably simply


Then do you want to return back integer number of hours?
for_yanConnect With a Mentor Commented:
with rounding it should be , I guess, like that;

softblessAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.