0

I have a code which puts data in datatables and has time computation:

$.each(myObj[1], function(key,value) {
    var date_start = new Date(value.start_timestamp);
    var date_end = new Date(value.end_timestamp);
    var milisec = Math.abs(date_end - date_start);
    var seconds = milisec / 1000;
    var hours = parseFloat( seconds / 3600 );
    totalhours += hours;

    var isdaily = '';
    if(value.is_daily == 0)
    {
        isdaily = 'Added'
    }
    else
    {
        isdaily = 'Daily'
    }

    t.row.add( [
        value.id,
        value.task_description,
        value.start_timestamp,
        value.end_timestamp,
        hours.toFixed(2)+" hr(s)",
        value.name,
        value.assign,
        value.created_at,
        isdaily,
        value.status
    ] ).draw();
});

var final_compute = Math.ceil(totalhours.toFixed(2));
$('#totalhours').text(final_compute);
alert("Tasks from the last 12 hours generated.");

What happens is my variables milisec, seconds, hours has NaN values. Which turned out to be caused by date_start and date_end which says invalid date. But on chrome it works fine. My timestamp formart is something like 2016-05-04 23:00:00

jackhammer013
  • 2,295
  • 11
  • 45
  • 95

1 Answers1

0

You need provide a specific format in order to parse dates in Firefox. More information can be found here

pazcal
  • 929
  • 5
  • 26