Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

mRender and timezone....

$
0
0

hi, I'm calculating the "time since" on a column using mRender, to do so, I added a class to a span, and within a timer I select them and recalculate them. This way I don't refresh all data, but the one that I have to change.

If the user is in the same timezone as the server, no problem, however if the user is in a different timezone, mRender cut the timezone out of the date... is there a way for me to retrieve it?

thanks,
Luis

// table declaration...
{ "sTitle": "Wait" , "width": "100px",
"mRender": function (data, type, row) {
return '<span dt="' + row.dt + '" class="wait_secs" >' + 0 + '</span>';
},

//timer
var update_signal_wait = setInterval( function(){
// wait since signal arrival
var items = $(".wait_secs"); //get all visible items
$.each( items, function( i, item ) {

                   var cur = new Date();
                   var sdt = new Date(item.getAttribute("dt"));
                   var diff = (cur.getTime() - sdt.getTime()) / 1000;
                   var res = '';

                   if ( diff <60)
                     res = diff.toFixed(1).toString() + ' s';
                     else {
                       diff = diff / 60;
                       if ( diff <60)
                         res = diff.toFixed(1).toString() + ' m';
                         else {
                           diff = diff / 60;
                           res = diff.toFixed(1).toString() + ' h';
                           }
                   }
                   item.innerHTML = res;

                  });



                },3000);

Viewing all articles
Browse latest Browse all 2364

Trending Articles