DataTable "Today"

Display the word "Today" instead of the date format in the table.

by mauricetwomey

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="//cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.21/js/jquery.dataTables.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src="https://cdn.datatables.net/plug-ins/1.10.25/sorting/datetime-moment.js"></script>
    <!-- Make sure you add today's date to the table! -->
    <div class="container">
      <div class="row">
        <div class="col">
          <div class="table-responsive">
              <table class="table" id="orders">
                  <thead>
                      <tr>
                          <th scope="col">Invoice</th>
                          <th scope="col">Order Date</th>
                          <th scope="col">Order Status</th>
                          <th scope="col">Deliver Date</th>
                          <th scope="col"># Items</th>
                      </tr>
                  </thead>
                  <tbody>
                      <tr>
                          <td>
                            467328
                          </td>
                          <td>
                              Mon 16 Aug 2021 <!-- change this to today! -->
                          </td>
                          <td>
                              New
                          </td>
                          <td>
                          </td>
                          <td>
                              56
                          </td>
                      </tr>
                      <tr>
                          <td>
                              412199
                         ...

JavaScript

$(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"]],
        "columnDefs": [{
          "targets": [1,3],
          "createdCell": function(td, cellData, rowData, row, col) {
            if (moment(cellData).isSame(moment(), "day")) {
              $(td).html('Today')
            }
          }
        }]
    });
});