2013-06-03 127 views
-6

在我的PHP文件,日期格式为:“2012年10月9日00:00:00”;我需要把它显示为“10月9日”或“10月9日”(不包括当年)。如何更改日期格式?

我怎样才能做到这一点?

+2

任何努力给予?你试过或搜索过任何东西吗? – Rikesh

+0

它很容易'回声日期( “M d” 的strtotime($自))' – webGautam

+1

谢谢kiamlaluno,Rikesh,webGautam – Monisha

回答

4

试试这个:

echo date("M, d", strtotime($from)); 
+0

谢谢:)哈西娜 – Monisha

+1

你的欢迎...... !!!! :) – Hasina

3
<?php 
$from= "2012-10-09 00:00:00" 
echo date('F n Y, strtotime($from)); // n-day, F- full month name, Y-Year 
?> 

请检查该链接以供参考:http://php.net/manual/en/function.date.php 您可以跳过上面的“Y”,从输出中删除的一年。

+1

$ from =“2012-10-09 00:00:00”; 回波日期( 'M J',的strtotime($从)); //导致10月9日 – Monisha

+1

谢谢cartina :) – Monisha