Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda