Skip to content

Instantly share code, notes, and snippets.

@stnadmin
Created April 16, 2015 20:01
Show Gist options
  • Save stnadmin/c1292141fcca7001978d to your computer and use it in GitHub Desktop.
Save stnadmin/c1292141fcca7001978d to your computer and use it in GitHub Desktop.
In common.php
<link rel="stylesheet" type="text/css" href="css/winter.css" id="siteCSS"/>
<script type="text/javascript">
// Get current month
var currDate=new Date();
var currMonth = currDate.getDate();
// Month returned by getDate() is 0 to 11 so add 1
currMonth = parseInt(currMonth) + 1;
// Based on month assign style sheet name
var newCSS = "default.css";
if (currMonth >= 1) newCSS = "winter.css"; // Month is January or greater
if (currMonth >= 3) newCSS = 'spring.css'; // Month is March or greater
if (currMonth >= 11) newCSS = 'winter.css'; // Month is June or greater
// Assign new style sheet name as the new href for "siteCSS" LINK tag
document.getElementById('siteCSS').href = newCSS;
</script>
</head>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment