Date format

Date format

calacala Posts: 52Questions: 15Answers: 0

Hi,

I have a date column in my table. Without any configuration, in the Editor the format is dd/mm/yyyy, but when the table is shown, it is mm/dd/yyyy.

How can I correct the visualization in the table?

Thank you!

This question has an accepted answers - jump to answer

Answers

  • btreebtree Posts: 99Questions: 14Answers: 11
    edited October 2015 Answer ✓

    Hi,

    you can use the "Set" formatter if you use php and editor.
    https://editor.datatables.net/manual/php/formatters

    If you only want to change the visual in the table you also can use the "render" function.
    https://datatables.net/reference/option/columns.render

    Cheers
    Hannes

  • calacala Posts: 52Questions: 15Answers: 0
    edited October 2015

    Thanks Hannes!

    For users that have same problem, I've used:

    var table=$('#my_table').DataTable( {
        columns: [
            ...many columns...
            { 
                data: "my_date_column_name",
                render: function (data) {
                    if(data === ""){
                        return '00-00-0000';
                    }       
                    from = data.split("-");
                    f = from[2]+'-'+ from[1]+'-' + from[0];
                    return f;
                }   
            }
        ]
    })
    
This discussion has been closed.