Re: detecting leap years?
| From: | Richard | Date: | Sat, 20 Jan 2018 01:43:57 +0000 |
| Subject: | Re: detecting leap years? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326364@lists.php.net to get a copy of this message | ||
> Date: Friday, January 19, 2018 20:36:51 -0500
> From: Aziz Saleh <azizsaleh@gmail.com>
>
> On Fri, Jan 19, 2018 at 8:34 PM, Jeffry Killen
> <jekillen@prodigy.net> wrote:
>
>> Is there a function for detecting leap years?
>>
>> I have developed a calendar generation module
>> that relies on javascript to let it know that a year
>> to be rendered in html markup is a leap year, so
>> it can add an extra day to February.
>>
>> When the host html first loads, the module defaults
>> to the current year. So it doesn't get to the point that
>> javascript can decide and return its judgment.
>> I am using getDate to determine the current year.
>> I need to determine if a current year is a leap year.
>>
>> I have written one for javascript, if there isn't a
>> built in function in php I can translate the js to php.
>>
>
> function is_leap_year($year) {
> return ((($year % 4) == 0) && ((($year % 100) != 0) || (($year %
> 400) == 0)));}
>
> Source:https://davidwalsh.name/checking-for-leap-year-using-php
Or the "L" parameter:
L Whether it's a leap year -- 1 if it is a leap year, 0 otherwise.
on the date() function:
<http://php.net/manual/en/function.date.php>