DataTables example Auto-locale display

In combination with DataTables' auto detection of ISO8601 formatted date / time strings, it is also possible to use it as a locale renderer, without an external library, as long as the data source is ISO8601. This is done through the Javascript toLocaleString() method.

In this example the ISO8601 formatted date in the fourth column is automatically shown in the table in a format suitable for the end user's browser. e.g. in Europe the format might be D/M/Y, while in the USA M/D/Y will be shown, without any additional configuration.

NamePositionOfficeAgeStart dateSalary
Airi Satou Accountant Tokyo 33 11/28/2008 $162,700
Angelica Ramos Chief Executive Officer (CEO) London 47 10/9/2009 $1,200,000
Ashton Cox Junior Technical Author San Francisco 66 1/12/2009 $86,000
Bradley Greer Software Engineer London 41 10/13/2012 $132,000
Brenden Wagner Software Engineer San Francisco 28 6/7/2011 $206,850
Brielle Williamson Integration Specialist New York 61 12/2/2012 $372,000
Bruno Nash Software Engineer London 38 5/3/2011 $163,500
Caesar Vance Pre-Sales Support New York 21 12/12/2011 $106,450
Cara Stevens Sales Assistant New York 46 12/6/2011 $145,600
Cedric Kelly Senior Javascript Developer Edinburgh 22 3/29/2012 $433,060
NamePositionOfficeAgeStart dateSalary
Showing 1 to 10 of 57 entries

The Javascript shown below is used to initialise the table shown in this example:

1
2
3
4
5
6
7
8
9
10
$(document).ready(function () {
    $('#example').DataTable({
        columnDefs: [
            {
                target: 4,
                render: DataTable.render.date(),
            },
        ],
    });
});

In addition to the above code, the following Javascript library files are loaded for use in this example: