Dismiss
  • Toggle Theme
  • View as Mobile

How to run JavaScript function on a specific day of the year

This snippet will run a specific function on April 1st. AKA april fools day.

Make sure you incorporate it into your site and replace all your site links with links to the rick roll video!

/* Check if it is april fools day */
var aprilFools = {
  month: 3,
  date: 1
}

function isItAprilFoolDay() {
  var now = new Date();
  return (now.getMonth() == aprilFools.month && now.getDate() == aprilFools.date);
}

if(isItAprilFoolDay()){
  // fuck with people
} else {
  // there is less fake stuff today
}

Link to gist