Client Side UTC to Locale
Client Side UTC to Locale
[Deleted User]
Posts: 0Questions: 0Answers: 0
[code]$(document).ready(function() {
$('#data').dataTable({
"bProcessing": true,
"sAjaxSource": "/json",
"aaSorting": [[0,'desc']],
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": "1024px"
});
$('tbody tr td:first-child').each(function() {
var utc = $(this).text();
var date = new Date(utc);
$(this).text(date);
});
});[/code]
I need some further processing done after/during the table is created. But with the second jQuery function doesn't seem to work, but if I do it after the building of the table (manually) it works.
Current data: 2012-09-05T14:17:38
Wanted data: Wed Sep 05 2012 09:17:38 GMT-0500 (Central Daylight Time)
$('#data').dataTable({
"bProcessing": true,
"sAjaxSource": "/json",
"aaSorting": [[0,'desc']],
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": "1024px"
});
$('tbody tr td:first-child').each(function() {
var utc = $(this).text();
var date = new Date(utc);
$(this).text(date);
});
});[/code]
I need some further processing done after/during the table is created. But with the second jQuery function doesn't seem to work, but if I do it after the building of the table (manually) it works.
Current data: 2012-09-05T14:17:38
Wanted data: Wed Sep 05 2012 09:17:38 GMT-0500 (Central Daylight Time)
This discussion has been closed.
Replies
$(document).ready(function() {
$('#data').dataTable({
"bProcessing": true,
"sAjaxSource": "/json",
"aaSorting": [[0,'desc']],
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": "1024px"
});
$('#data').bind('init', function() {
$(this).find('tbody tr td:first-child').each(function() {
var utc = $(this).text();
var date = new Date(utc);
$(this).text(date);
});
});
});
[/code]
New working code!! Waahoo!
$(document).ready(function() {
$('#data').dataTable({
"bProcessing": true,
"sAjaxSource": "/json",
"aaSorting": [[0,'desc']],
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": "1024px"
});
$('#data').bind('draw', function() {
$(this).find('tbody tr td:first-child').each(function() {
var utc = $(this).text();
var date = new Date(utc);
$(this).text(date);
});
});
});
[/code]
Seems I may want to bind to 'draw' instead of 'init'. Fully working code.