I'm trying to calculate time difference for each of the data gotten from database but it displays NaN Instead of the time difference
$(document).ajaxError(function(event, request, settings) {
$('#busy').hide();
alert("Error accessing the server");
});
function getEmployeeList() {
$('#busy').show();
$.getJSON(serviceURL + 'getemployees.php', function(data) {
$('#busy').hide();
$('#employeeList li').remove();
employees = data.items;
$.each(employees, function(index, employee) {
var valuestart = $("00:00:00");
var valuestop = $("05:00:00");
var timeStart = new Date("01/01/2007 " + valuestart).getHours();
var timeEnd = new Date("01/01/2007 " + valuestop).getHours();
var difference = timeEnd - timeStart;
$('#employeeList').append('<li><a href="employeedetails.html?id=' + employee.id + '">' +
'<img src="js/citybus.png" class="list-icon"/>' +
'<p class="line1">' + employee.firstName + '</p>' +
'<p class="line2">' + difference + '</p>' +
'<span class="bubble">' + employee.managerId + '</span></a></li>');
});
var valuestart = "00:00:00";
var valuestop = "05:00:00";
You're concatenating a string with an jQuery object when creating a new Date.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.