Venki Chikkanti
Venki Chikkanti

Reputation: 103

How to Get Difference between two datetimes in asp.net using javascript

i have

 var hours = sender.get_selectedDate() - LoginTime.get_selectedDate();
 var Hou = parseFloat((hours % 86400000) / 3600000).toFixed(2);

I am getting hours = 34200000 and Hou = 9.50

But i need to get 9 Hours and 30 Minits

how to do this...

Upvotes: 0

Views: 140

Answers (2)

Shiplu Mokaddim
Shiplu Mokaddim

Reputation: 57650

Converting 9.5 to 9:30 is easy, isn't it? Just use simple math.

h=Math.floor(Hou);
m=(Hou-h)*60;
s=h+":"+m // s= '9:30'

Upvotes: 1

LearningAsp
LearningAsp

Reputation: 361

use timespan type ..and you can directly add or subtract using its properties.

click here for timespan

Upvotes: 0

Related Questions