I am trying to create a ‘Dynamic’ page that will change the heading text of the page / site with each season (based on Australian seasons). eg. When current month is March, my heading need to change to Autumn. Like that depending on the month it need to change to Summer, Winter, Autumn and Spring as well as an added feature for DAY Specific Christmas and New Years.
I found this script but I don’t know how to implement. Could someone please help, because it is not working!!! Thanks
// Return the southern hemisphere season for a date
// If no date provided, uses current system date
function getSeason(d) {
d = d || new Date();
var mon = d.getMonth() + 1; // Adjust to be indexed from 1
var day = d.getDate();
var seasons = [‘summer’,‘autumn’,‘winter’,‘spring’];
// Do silly seasons here
if (mon == 12) {
if (day >= 13 && day <= 27) {
return ‘xmas’;
}
if (day >= 28 && day <= 31) {
return ‘nye’;
}
}
// If wasn’t a silly season, do others
mon = Math.floor((mon % 12) / 3);
return seasons[mon];
}
console.log('Currently it is ’ + getSeason()); // Currently it is summer
$(document).ready(function(){
document.body.className = getSeason();
});