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的閱讀是Strftime日期更改與php和Mysql
2013-06-03 00:18:32
我想簡單地說,只顯示日期而不是時間。當我在腳本中時,我似乎無法弄清楚如何去做。我試過
$postdate = strftime("%b %d, %Y", strtotime($row["postdate"]));
這是行的遏制,不能弄清楚。我應該在什麼時候輸出這些更改和任何參考,爲什麼會不勝感激。
這是極好的!萬分感謝。我一直在研究這裏,試圖弄清楚這一點。所以我更好地理解了......在什麼時候進行了轉換?正如它被稱爲? –
@HireLogo轉換已經在您調用date和strtotime函數時完成,您可以按照我的工作示例進行打印,也可以將其存儲在一個變量中,以便稍後根據代碼建議進行打印。如果你認爲答案是正確的,請接受它以幫助在未來遇到類似問題的人 – Fabio