格式化日期

时间:2012-03-08 03:17:18

标签: php

  

可能重复:
  Date formatting in PHP

在我的print_r函数内部运行时显示$ message-> date_sent为2012-03-05 00:00:00

echo '<td>'.date('F d, Y', $message->date_sent).'</td>';

很明显日期功能不是我想要的,因为我只想把它变成2012年3月5日。

2 个答案:

答案 0 :(得分:2)

调用strtotime到第二个参数

echo '<td>'.date('F d, Y', strtotime($message->date_sent)).'</td>';

答案 1 :(得分:0)

对于月份的长记法 2012年1月12日

<?php echo '<td>'.date("F d Y", strtotime($message->date_sent)) .'</td>'; ?>

简称月份 2012年1月12日

<?php echo '<td>'.date("M d Y", strtotime($message->date_sent)) .'</td>'; ?>
相关问题