简体   繁体   中英

Datatable > highlight date

I am using datatable framework an I want to highlight date which has been passed away

for example now it is 12:00 AM if there is any row how have date and time before 12:00 AM today it should be red

This is the code that I am trying to edit

 "createdRow": function ( row, data, index ) {
            if ( data[10].replace(/[\$,]/g, '') * 1 < 150000 ) {
                $('td', row).eq(10).addClass('highlight');
            }
        }  ,

basically my idea is to make this code look like this

        if ( data[10].replace(/[\$,]/g, '')  < now) {

my time format is like this

2016-09-01 05:09:07

any ideas ?

var dt = '2016-09-01 05:09:07'.replace(/\s/, 'T') + 'Z';
console.log((new Date(dt)) > (new Date()));

For more information you can see here: Converting string to date in js

If you want highlight datetime ranges you can increase/decrease Date object state.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM