如何使用php从mysql datetime中删除重复的一天

如何使用php从mysql datetime中删除重复的一天

问题描述:

Following php scripts

 <?php 
echo date('D, F d ', strtotime($event->starttime)); echo $this->timestamp(strtotime($event->starttime));    
?>

display result as,

Mon, March 21 Mon at 8:00 AM

Fri, March 25 Fri at 9:00 AM

etc

Unfortunately its showing day (Here, Mon and Fri) twice. Here how to remove the second day( ie, before string at). I would like to show output as

Fri, March 25 at 9:00 AM

Any help please...

以下php脚本 p>

 &lt;?php 
echo date  ('D,F d',strtotime($ event-&gt; starttime));  echo $ this-&gt; timestamp(strtotime($ event-&gt; starttime));  
?&gt; 
  code>  pre> 
 
 

显示结果为, p>

 星期一,3月21日星期一上午8:00  
 
Fri,3月25日星期五上午9点
 
etc 
  code>  pre> 
 
 

不幸的是它显示了一天(这里,周一和周五)两次。 这里是如何删除第二天(即在 code>之前的字符串之前)。 我希望将输出显示为 p>

星期五,3月25日上午9:00 code> p>

请提供任何帮助。 .. p> div>

echo strftime('%a, %B %d at %I:%M %p', strtotime($event->starttime));

You don't need two echoes for this, one echo is enough. You can add the 'at' text yourself, if you prepend it with a backslash.

From the PHP Date function:

<?php 
echo date('D, F d \a\t H:i A', strtotime($event->starttime));
?>

A lowercase d passed to date() should return only the day number... check out http://php.net/manual/en/function.date.php for a list of all the valid parameters.

Try removing the space following d?