Here, I included my time difference code, but I am getting NaN error.
How to do time difference in my code.
I need my output like,
03 Hrs : 30 Mins
Here is my code:
/////Calculate time duration start///////
/*function calculate_Duration()
{
//var start_time = document.getElementById('start_time').value;
//var end_time = document.getElementById('end_time').value;
var start_time = "10:00 AM";
var end_time = "01:30 PM";
//alert(start_time);
var stSplit_Start = start_time.split(" ");
var stHour_Start = stSplit_Start[0]+":"+"00";
var stFrmt_Start = stSplit_Start[1];
//alert(stHour_Start);alert(stFrmt_Start);
if(stHour_End > stHour_Start)
{
res = (stHour_End - stHour_Start)/1000*60*60*24;
alert(res);
}
else
{
alert("Can`t Calculate Duration");
}
//}
/////Calculate time duration end////////
</script>
datewill be any date, I do not want date with time calculation
AntonyRayan
15
Posting Whiz in Training
Recommended Answers
Jump to PostHere is the the input/output I tested...
calculateTimeDifferenceInTheSameDay("01:30 pm", "07:15 pm") // output 20700000
All 4 Replies
cereal
1,524
Nearly a Senior Poster
Featured Poster
Taywin
312
Posting Virtuoso
AntonyRayan
15
Posting Whiz in Training
Taywin
312
Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.