【发布时间】:2018-09-19 08:15:58
【问题描述】:
如果结束日期小于今天的日期,我需要在每行的标题附近显示一条名为 expired 的消息。这将在 jquery 中使用悬停来完成。
我的表格视图如下:
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Start Date</th>
<th scope="col">End Date</th>
<th scope="col">Description</th>
<th scope="col">Edit</th>
</tr>
</thead>
<tbody>
<?php foreach($offerList as $info){ ?>
<tr>
<td><a href="<?php echo base_url()."offer/publicview/?id=".urlencode($this->encrypt->encode($info->offid)); ?>"><?php echo $info->title; ?></a></td>
<td><?php echo $info->startdate; ?></td>
<td><?php echo $info->enddate; ?></td>
<td><?php echo $info->discrip; ?></td>
<td>
<a href="<?php echo base_url()."offer/edit/?id=".urlencode($this->encrypt->encode($info->offid)); ?>">Edit</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
jquery:
<script>
var today = t.getDate() + '/' + (t.getMonth()+1) + '/' + t.getFullYear() ;
$( "tr" ).hover(
function() {
$( this ).append( $( "<span> expired </span>" ) );
}, function() {
$( this ).find( "span:last" ).remove();
});
$( "tr.fade" ).hover(function() {
$( this ).fadeOut( 100 );
$( this ).fadeIn( 500 );
});
</script>
我需要获取每一行的结束日期并将其与今天的日期进行比较。如果结束日期小于今天的日期,则消息应显示在标题附近。
对此有什么想法吗?我不知道如何获取每行的结束日期。
【问题讨论】:
-
$enddate的格式是什么? 2018 年 9 月 19 日? -
嗨@Alex 它是 2018-09-21
标签: jquery codeigniter date if-statement