That's simple. I won't write the function out for you, but I'll give you the gist of what you need to do!
Now, you know every month has a 1st, so you don't need to use that every time. What you need to do is get the start date (2002-01-01) and increment each month (2002-02-01, etc) until it hits 12! Then you need to start from 1 again, and increment the year! It's simple enough, you should be able to make that!
Once you've got the date in a YYYY-MM-DD format, you can use the date function to display it as whatever you like!