Last active
December 27, 2015 08:09
-
-
Save ingozoell/7294202 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.evening {background: #999;} | |
/* ... */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$(document).ready(function () { | |
datetoday = new Date(); // create new Date() | |
timenow = datetoday.getTime(); // grabbing the time it is now | |
datetoday.setTime(timenow); // setting the time now to datetoday variable | |
hournow = datetoday.getHours(); //the hour it is | |
if (hournow >= 18) // if it is after 6pm | |
$('body').addClass('evening'); | |
else if (hournow >= 12) // if it is after 12pm | |
$('body').addClass('afternoon'); | |
else if (hournow >= 6) // if it is after 6am | |
$('body').addClass('morning'); | |
else if (hournow >= 0) // if it is after midnight | |
$('body').addClass('midnight'); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment