foreach中的日期格式类型“datetime”

时间:2016-09-27 00:59:31

标签: php datetime

我正在尝试格式化我的约会但不是我做错了什么?

此代码未显示错误。 “回声”是空的。

<?php foreach ($Data as $v1) { ?>
<div class="panel panel-default">
 <div class="panel-heading">Published by <?=$v1->username?> Date: <?php echo DateTime::createFromFormat('d-m-Y H:i', $v1->date); ?></div>
  <div class="panel-body">
   <?=$v1->text?>
  </div>
</div>
<?php } ?>

1 个答案:

答案 0 :(得分:-1)

能够找到解决方案!我同意答案,所以你看到别人为你服务!

<?php foreach ($Data as $v1) { ?>
<div class="panel panel-default">
 <div class="panel-heading">
  Published by <?=$v1->username?> 
  Date: <?php 
  $date = date_create($v1->fecha); 
  echo date_format($date, 'd-m-Y H:i'); 
  ?>
</div>
  <div class="panel-body">
   <?=$v1->text?>
  </div>
</div>
<?php } ?>