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      
softblessAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
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)
0
 
for_yanCommented:
But I guess you have it in JavaScript ?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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

 (d1.getTime()-d2.getTime())/3600000

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

 Math.round((d1.getTime()-d2.getTime())/3600000)
0
 
softblessAuthor Commented:
thanks
0
All Courses

From novice to tech pro — start learning today.