How to check whether the current year is a leap year in PHP?

A leap year is a year that has 366 days that Includes an extra day in February. It occurs once every 4 years with the next leap year occurring in 2020. You would think that finding a leap year would Involve some complex calculation. But, in PHP it is just a single line of code that determines whether the current year is a Leap Year or not.

It uses the date library function.

date("L");

This returns a boolean value. 1 being that the current year is a leap year and 0 if it is not.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s