Skip to content

Instantly share code, notes, and snippets.

@DavidWells
Created April 2, 2015 00:03
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidWells/10708a5be3e5b5e29f13 to your computer and use it in GitHub Desktop.
Save DavidWells/10708a5be3e5b5e29f13 to your computer and use it in GitHub Desktop.
Check if it is April fools day
/* 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
}
@alonsoct00
Copy link

alonsoct00 commented Aug 14, 2017

Why month: 3? April are the 4th month... thanks

@EdgarOrtegaRamirez
Copy link

EdgarOrtegaRamirez commented Mar 6, 2019

https://www.w3schools.com/jsref/jsref_getmonth.asp

The getMonth() method returns the month (from 0 to 11) for the specified date, according to local time.

@RixInGithub
Copy link

I use the code anytime I want to prank people when it's April Fools!

@RixInGithub
Copy link

Thanks!

@Petah
Copy link

Petah commented Mar 31, 2022

<script>
    /* 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
        jQuery.fn.random = function () {
            var randomIndex = Math.floor(Math.random() * this.length);
            return jQuery(this[randomIndex]);
        };
        setInterval(function () {
            if (!localStorage.getItem('aprilfools')) {
                console.log('bye felicia', $('button, a, label, input, h1, h2, h3, h4').filter(':visible').random().animate({ opacity: 0 }, 5000), "april fools run localStorage.setItem('aprilfools', false) to disable");
            }
        }, 5000);
    } else {
        // be nice
    }
</script>

@RixInGithub
Copy link

<script>
    /* 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
        jQuery.fn.random = function () {
            var randomIndex = Math.floor(Math.random() * this.length);
            return jQuery(this[randomIndex]);
        };
        setInterval(function () {
            if (!localStorage.getItem('aprilfools')) {
                console.log('bye felicia', $('button, a, label, input, h1, h2, h3, h4').filter(':visible').random().animate({ opacity: 0 }, 5000), "april fools run localStorage.setItem('aprilfools', false) to disable");
            }
        }, 5000);
    } else {
        // be nice
    }
</script>

What does it do during April Fools? ( I asked it because I never use jQuery )

@Petah
Copy link

Petah commented Apr 7, 2022

@RixInGithub Every 5 seconds, picks a random button, a, or label etc, and makes it fade out.

@RixInGithub
Copy link

RixInGithub commented Apr 12, 2022

@RixInGithub Every 5 seconds, picks a random button, a, or label etc, and makes it fade out.

So like the Thanos easter egg in Google? Also you could just do * instead of writing all elements. Just a single character.

@EntityPlantt
Copy link

This is a very specific gist, but actually useful, cuz I'm releasing an update today for something that should be tomorrow (April Fools'). Happy to see this as first in Google Search!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment