Hi All,
Please find the below Code to get the Hours/Seconds difference from DateTime using Javascript
function Onload()
{
var d2 = new Date(), // Pass 2nd Date Time
dformat = [d2.getMonth() + 1,
d2.getDate(),
d2.getFullYear()].join('-') + ' ' +
[d2.getHours(),
d2.getMinutes(),
d2.getSeconds()].join(':');
var d1 = new Date(), // Pass 1st Date Time
dformat = [d1.getMonth() + 1,
d1.getDate(),
d1.getFullYear()].join('-') + ' ' +
[d1.getHours(),
d1.getMinutes(),
d1.getSeconds()].join(':');
var seconds = (d2 - d1) / 1000; // You will get Second Diff between two date
var diffHrs = Math.floor(seconds / (60 * 60)); // You will get Hours Diff between two date
}
Please find the below Code to get the Hours/Seconds difference from DateTime using Javascript
function Onload()
{
var d2 = new Date(), // Pass 2nd Date Time
dformat = [d2.getMonth() + 1,
d2.getDate(),
d2.getFullYear()].join('-') + ' ' +
[d2.getHours(),
d2.getMinutes(),
d2.getSeconds()].join(':');
var d1 = new Date(), // Pass 1st Date Time
dformat = [d1.getMonth() + 1,
d1.getDate(),
d1.getFullYear()].join('-') + ' ' +
[d1.getHours(),
d1.getMinutes(),
d1.getSeconds()].join(':');
var seconds = (d2 - d1) / 1000; // You will get Second Diff between two date
var diffHrs = Math.floor(seconds / (60 * 60)); // You will get Hours Diff between two date
}
No comments:
Post a Comment