Correct use of easter_days() function in PHP

autoload
Release: 2023-03-09 12:14:02
Original
1594 people have browsed it

Correct use of easter_days() function in PHP

PHPThere are many functions related to date. Some of them are special functions that are not commonly used, but they need to be used in some special cases, such as You need to specify the number of days between March 21st and Easter of the year. In this case, you need theeaster_days()function. This article will take you to take a look.

First let’s take a look at the syntax of theeaster_days()function

easter_days ( int $year = ? , int $method = CAL_EASTER_DEFAULT )
Copy after login
  • $year: year in positive form, if no year is specified , the default is the current year.

  • $method: When set to CAL_EASTER_ROMAN, the Gregorian calendar can be used to calculate the Easter date between 1582-1752

  • Return value: Returns the number of days from March 21st to Easter based on the given parameter year.

Code example:

1. Parameterless form

";
Copy after login
输出:14
Copy after login

2. Parameterized form

"; echo easter_days(2021); echo "
"; echo easter_days(1999); echo "
"; echo easter_days(1492); echo "
"; echo easter_days(1913); ?>
Copy after login
输出:27 14 14 32 2
Copy after login

Recommendation:2021 PHP interview questions summary (collection)》《php video tutorial

The above is the detailed content of Correct use of easter_days() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!