Database inside Time word Gencun is int type time stamp, want to make below this effect, have no experience, hope everybody can give a thought, thank!
Reply content:
Database inside Time word Gencun is int type time stamp, want to make below this effect, have no experience, hope everybody can give a thought, thank!
sql = 'SELECT * FROM `table` ORDER BY created DESC';//你的数据库驱动逻辑//数据处理if ($articles) { $res = []; foreach ($articles as $article) { $year = date('Y', $article['created']); $res[$year][] = $article; //以年为单位,作为数组索引, }}//最后输出结果类似这样$res => [ [2014] => [ [0] => [ //article 1 ], [1] => [ //article 2 ] ], [2015] => [ [0] => [ //article 1 ], [1] => [ //article 2 ] ]]
order by 时间字段名 DESC //时间从大到小order by 时间字段名 ASC //时间从小到大
When you invoke the SQL statement, ORDER BY field_time Desc is not finished.
Think it should be possible to refer to a similar paging solution
is the conversion of the time type, with Strtotime.
$dated is the time stamp you took out.
Date ("Y", Strtotime ($dated)); Years
Date ("M/d", Strtotime ($dated)); Month/day