Loop Issue Counting Year In PHP

后端 未结 10 1295
陌清茗
陌清茗 2021-01-22 10:35

I have created a loop which will display date 2004 to 2014 in a formatted way. But the problem is, it is showing 204 instead of 2004 and continue this till 209.. So, how to show

10条回答
  •  無奈伤痛
    2021-01-22 10:56

    Why go through such a long and odd process, when you can do something like this?

    
    

    Output:

    01 Jan 2004
    02 Jan 2004
    03 Jan 2004
    ...
    29 Dec 2012
    30 Dec 2012
    31 Dec 2012
    

    This also has the added bonus of not showing "31 Feb 2008" etc., as that date doesn't even exist.

    Codepad example of the code (WARNING: long output!)

提交回复
热议问题