我试图timestamp
在 MySQL 中以秒、分钟、天等形式回显。
脚本运行良好,但我不得不稍微整理一下我的代码,现在它来不及了;它只是回显0 days
or0 hours
或0 whatever
。
这是我触摸时间码之前的样子,但我不能这样,因为我不得不编辑一些div
订单。
所以我的问题是,有人可以告诉我或告诉我我做了什么让它停止工作吗?谢谢你
以前是怎样的:
<div class="board-wall-feeds">
<div class="social_header">
<?php echo "$profile[2]" ?>'s News & Updates:
</div>
<?php
$timeline_set = get_timeline();
while ($news = mysql_fetch_array($timeline_set)) {
echo "
<div class=\"news_feeds_board_text\">{$news['content']}
<div class=\"social_footer\"><a href=\"../../../delete_news_post.php?to=".$news['id']."</div><div class=\"social_clip\"></div></a>"; ?>
<?
$datetime1 = new DateTime();
$datetime2 = new DateTime ($news['date_added']);
$interval = $datetime1->diff($datetime2);
$mdhms = explode('-',$interval->format('%m-%d-%H-%i-%s'));
$labels = Array(' months', ' days', ' hours', ' minutes', ' seconds');
$i = 0;
foreach($mdhms as $t){
if($t > 0) break;
$i+=1;
}
echo "about ".$t.$labels[$i]." ago"; ?></div></div>
<? } ?>
div
我的新订单现在如何:
<div class="board-wall-feeds">
<div class="social_header">
<?php echo "$profile[2]" ?>'s News & Updates:
</div>
<?php
$datetime1 = new DateTime();
$datetime2 = new DateTime ($news['date_added']);
$interval = $datetime1->diff($datetime2);
$mdhms = explode('-',$interval->format('%m-%d-%H-%i-%s'));
$labels = Array(' months', ' days', ' hours', ' minutes', ' seconds');
$i = 0;
foreach($mdhms as $t){
if($t > 0) break;
$i+=1;
}
$timeline_set = get_timeline();
while ($news = mysql_fetch_array($timeline_set)) {
echo "
<div class=\"news_feeds_board_text\">{$news['content']}
<div class=\"social_footer\">about ".$t.$labels[$i]." ago<a href=\"../../../delete_news_post.php?to=".$news['id']."</div><div class=\"social_clip\"></div></div></a>"; ?>
<? } ?>
</div>