简体   繁体   English

数据表>突出显示日期

[英]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 例如现在现在是12:00 AM,如果有任何行显示今天12:00 AM之前的日期和时间,则应为红色

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 有关更多信息,请参见此处: 在js中将字符串转换为日期

If you want highlight datetime ranges you can increase/decrease Date object state. 如果要突出显示日期时间范围,可以增加/减少“日期”对象状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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