2
<?php
    //run a select query to my latest 1 item
    include "storescripts/connect_to_mysql.php";
    // This block grabs the whole list for viewing
$dynamicList= "";
$sql = mysql_query("SELECT * FROM blog");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
    while($row = mysql_fetch_array($sql)){ 
             $id = $row["id"];
             $title = $row["title"];
             $author = $row["author"];
             $category = $row["category"];
             $article = $row["article"];
            // $postdate = strftime("%b %d, %Y", strtotime($row["postdate"]));
              $postdate = $row["postdate"];
             //Seperate so it's easier to see what i'm working with here.
             $short = substr(strip_tags($article), 0, 400);

             $dynamicList .= '<ul>
<li>
<div class="wrapFirstRowBlog">
    <div class="postDate">'.$postdate.'</div>
    <div class="nextToDate">
    <div class="blogTitle"><h3><a href="blog.php?id='.$id.'">'.$title.'</a></h3></div>
    <div class="author">written by '.$author.' for the '.$category.' section.</div>
    <div class="socialNetwork"></div>
    </div>
</div>
<div class="blogPreview">
<img class="blogLeft" src="../blog_images/'.$id.'.jpg" width="150" height"150" alt="'.$title.'"/>'.$short.'...<a href="http://www.moniquetrinidadjewelry.com/images/new-images/read-more.png"><img src="http://www.moniquetrinidadjewelry.com/images/new-images/read-more.png" alt="read more of this post" /></a>
</div>
</li>
</ul>';
    }
} else {
    $dynamicList = 'Nothing posted yet...check back soon!';
}
mysql_close();
?>

ここで検索された多くの組み合わせを試しましたが、スクリプト内で始めようとしていることができます。日付を単に日付を表​​示するように変換しようとしています。私のmysqlの読みは

2013-06-03 00:18:32 

時間を省略して、日付のみを表示するようにしたいと思います。スクリプト内にある場合、それを行う方法がわかりません。私はもう試した

$postdate = strftime("%b %d, %Y", strtotime($row["postdate"]));

これは行の包含であり、それを把握できません。どの時点でこれらの変更を出力する必要があり、その理由についての参照をいただければ幸いです。

4

1 に答える 1

2

date機能は使えると思います

$postdate = date("m d, Y", strtotime($row["postdate"]));

$postdateこれにより、変数に日付が格納されます

06 03, 2013

ライブデモ

于 2013-06-03T21:30:16.183 に答える