There's a table in my database that's dated.
News_last_modified
2013-04-12 13:04:18
It's the style.
How do I select a date instead of a time?
The code for the front desk is like this
Require_once (dir_ws_classes. ' news.php ');
$news _list_by_author_sql= ' Select N.article_id,n.news_last_modified, Nt.news_article_name from '. Table_news_articles. ' N left join '. Table_news_articles_text. ' NT on (n.article_id = nt.article_id and nt.language_id = \ '. (int) $_session[' languages_id '. ' \ ') and n.news_status = \ ' 1\ '. ' ORDER by n.article_id DESC limit 6 ';
$news = $db->execute ($news _list_by_author_sql);
if ($news->recordcount () > 0) {
$i = 0;
$article _array = Array ();
while (! $news->eof) {
$article _array[$i] = Array (
' ArticleID ' = $news->fields[' article_id '],
' Articledate ' = $news->fields[' news_last_modified '],
' ArticleName ' = stripslashes ($news->fields[' news_article_name '),
);
$i + +;
$news->movenext ();
}//end while
} else {
$articlesNotFound = true;
}
?>
-------------------------------------
' articledate ' = $news->fields[' news_last_modified ']
Please do me a favor. I'm a novice. Learning in progress
Reply to discussion (solution)
Date ()
$str = "2013-04-12 13:04:18"; $ar =explode ("", $str);p Rint_r ($ar);//array ([0] = 2013-04-12 [1] = = 13:04:18) $t = Explode ("", $news->fields[' news_last_modified ']); ' Articledate ' = $t [0],
$news _list_by_author_sql= ' Select n.article_id, Date_format (n.news_last_modified, "%y-%m-%d") as News_last_modified, Nt.news_article_name from '. Table_news_articles. ' N left join '. Table_news_articles_text. ' NT on (n.article_id = nt.article_id and nt.language_id = \ '. (int) $_session[' languages_id '. ' \ ') and n.news_status = \ ' 1\ '. ' ORDER by n.article_id DESC limit 6 ';
Or you can turn it in PHP.
' Articledate ' = Date ("y-m-d", Strtotime ($news->fields[' news_last_modified ')),
$news _list_by_author_sql= ' Select N.article_id,date_format (n.news_last_modified, "%y-%m-%d") as News_last_modified, Nt.news_article_name from '. Table_news_articles. ' N left join '. T......
Thank you. Now I understand how to do it. Debugging a bit also come out corresponding effect.