and like us on FB

On one of our aviation websites , we use a version of our Hiztory WP plugin to render a large amount of aviation history relevant to each day of the year (it’s actually an enhanced version of the plugin that we’re testing). As part of the process we had the need to generate a list of all the days in the year (in a loop) so as to create a readable text sitemap and, more importantly, an XML sitemap suitable for the likes of Google.

The following PHP function will load all the days of a defined year into an array.

To render the array on your page, you should use the following:

Of course, if you chose to loop through the array and print the result directly to the page, you could use something similar to the following. In this example, I’m printing a formatted date (the code is to be used in the function above).

I used a similar function to create the XML sitemap linked to below.


If you want to see an example, you can view the XML sitemap that was the motivation for the above code here .


Title: All Dates of a Year Into an Array with PHP
Description: All Dates of a Year Into an Array with PHP. Used to print out date-based XML sitemaps.
Download: PHP Code (V0.2) | Plugin Page

Shortt URL for this post: