[英]Shorten date notation codeigniter
I'm building a webapp with CodeIgniter and I want to show the latest posts. 我正在使用CodeIgniter构建一个Webapp,我想显示最新帖子。 I calculate the time between the date of posting and the current date.
我计算了发布日期和当前日期之间的时间。 The problem is that it shows like this: 1d 4h 2m or 9h 32m.
问题是它显示如下:1d 4h 2m或9h 32m。 So I actually want only to show the 1d or 9h in this case.
因此,在这种情况下,我实际上只想显示1d或9h。 How is this possible?
这怎么可能?
This is how I calculate the time: 这是我计算时间的方式:
span class="time"><?php
$this->load->helper('date');
$post_date = strtotime($t['story_date']);
$now = strtotime(date('Y-m-d H:i:s'));
echo timespan($post_date, $now);
?> </span>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.