Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
Display the word "Today" instead of data format in Datatable.js table

I would like to display the word "Today" instead of, for example, "Mon 16 Aug 2021" in my Datatable.js table.

See fiddle here: https://jsfiddle.net/mauricetwomey/nsbk7Lry/62/

I would like the result to display "Today" wherever today's date is in the table:

datatable

I am using moment.js to handle the date formatting but I cannot get the locale feature to automatically change a date format to a string.

$(document).ready( function () {
    $.fn.dataTable.moment('ddd D MMM YYYY');
    var table = $("#orders").DataTable({
        columns: [
            { orderable: !1 },
            { orderable: !0 },
            { orderable: !1 },
            { orderable: !1 },
            { orderable: !1 },
        ],
        order: [[1, "desc"]],
    });
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could do this using createdCell

"columnDefs": [{
  "targets": [1,3],
  "createdCell": function(td, cellData, rowData, row, col) {
    if (moment(cellData).isSame(moment(), "day")) {
      $(td).html('Today')
    }
  }
}]

Fiddle : https://jsfiddle.net/mauricetwomey/nsbk7Lry/69/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!