如何使用回声更改日期格式?

时间:2014-05-11 11:46:22

标签: php date echo

echo "<p>These are the available venues for $date that also have the catering 
grade of <b>$catering_grade </b> </p>";

这就是它的结果:

这些是 2014-05-13 的可用场地,其餐饮等级为3

如何在回声中将格式更改为DD / MM / YYYY?

2 个答案:

答案 0 :(得分:0)

你需要

strtotime()date()

$originalDate = "2014-05-13";
$newDate = date("d-m-Y", strtotime($originalDate));

Working Demo

所以在你的视图中

 <?php
echo "<p>These are the available 
venues for " . date("d-m-Y", strtotime($date)) . " that 
also have the catering 
grade of <b>$catering_grade </b> </p>";
?> 

Working Demo

答案 1 :(得分:0)

date("d/m/Y", strtotime($date));
  

OR

$date = '2010-05-13';
$date = str_replace('-', '/', $date);
echo date('d-m-Y', strtotime($date));