The time field in the database is an int-type Timestamp. If you want to make the following effect, you have no experience. I hope you can give me some ideas. Thank you!
The time field in the database is an int-type Timestamp. If you want to make the following effect, you have no experience. I hope you can give me some ideas. Thank you!
Reply content:
The time field in the database is an int-type Timestamp. If you want to make the following effect, you have no experience. I hope you can give me some ideas. Thank you!
SQL = 'select * FROM 'table' ORDER BY created desc'; // your database driver logic // data processing if ($ articles) {$ res = []; foreach ($ articles as $ article) {$ year = date ('y', $ article ['created ']); $ res [$ year] [] = $ article; // year as an array index ,}} // The final output result is similar to this: $ res => [[2014] => [[0] => [// article 1], [1] => [// article 2], [2015] => [0] => [// article 1], [1] => [// article 2]
Order by time field name DESC // time from large to small order by time field name ASC // time from small to large
When you call an SQL statement, order by field_time desc is not finished.
I think it should be possible to refer to solutions similar to Paging
Is the time type conversion. Use strtotime
$ Dated is the timestamp you took out.
Date ("Y", strtotime ($ dated); // year
Date ("m/d", strtotime ($ dated); // month/day