conditional formatting html table in php with time stamp comparison

后端 未结 3 1573
梦如初夏
梦如初夏 2021-01-28 03:03
echo \'\';
echo \'\'; 
echo \'\';
echo \'
3条回答
  •  迷失自我
    2021-01-28 03:41

    It seems like your timestamp is a String, you need to convert your string to a Unix TimeStamp using strtotime:

    $rowTime=strtotime($row['TimeStamp']);
    

    and then substract it from the actual time, as the previous answer, to obtain the difference in seconnds. Divide it by 60 and you get it on minutes.

    $currenTime=time();
    $diffSeconds=$currenTime-$rowTime;
    $diffMinutes=$diffSeconds/60;
    

    and then check if the difference is bigger than 60:

    $myCSS="normalRow";
    if ($diffMinutes>60) { $myCSS="differentRow"; }
    

    and then use that CSS Style ($myCSS) in your table row:

    echo '
OrderDestinationLocation
';

You need to define those two styles in your CSS file or your HTML Header like:


And that's it. Hope it helps.

提交回复
热议问题