开发者

getting a date array from a mysql database?

开发者 https://www.devze.com 2023-01-02 22:33 出处:网络
I have a database with date field is this format \"2010.06.11. | 10:26 13\" What is need is a php array that would hold all the different dates, .i.e.

I have a database with date field is this format "2010.06.11. | 10:26 13"

What is need is a php array that would hold all the different dates, .i.e.

array[0] = "2010.06.09."

array[1] = "2010.06.10."

array[2] = "2010.06.11."

Currently I am doing it by selecting the whole table, then looping through the result and adding the date substr to an array if it is not already there.

Bu开发者_JAVA技巧t maybe there is a faster way? Thanks.


You can directly select only the distinct dates from the database:

SELECT DISTINCT SUBSTRING(date, 1, 11) AS date_string FROM table
0

精彩评论

暂无评论...
验证码 换一张
取 消