It turns out that if you call date.getFullYear() (which is what I used in this example), you can use it to get any date in the format: YYYY.MM.DD or YYYYMMDD. Here’s a link to a demo page where you can play with the code and see how it works.
The demo page has a date function you can use to get the current year. It doesn’t work in IE but it works in Chrome so you should use that method. So the main trick is to create a function called getCurrentYear and use that in your date function.
It also turns out that it is possible to use Date.getFullYear to get any date in the format YYYY.MM.DD. It seems that there is a slight difference in how these two date functions are constructed, but they are not the same.
We have more of this. I’ve been using date1.getFullYear() in my blog for several years and it seems to work well on Chrome. It’s a good time of year, but it’s not perfect. I’m going to start my own project where I think about using getCurrentYear() on my website to get my current year.