PHP easter_date Function

Today, we are going to learn about easter_date.

So, what is easter_date() in PHP?

The easter_date() function returns the Unix timestamp for midnight on Easter of a specified year.
Syntax of this function:
easter_date(year) year - defines the year to calculate the midnight on Easter from. If the year parameter is omitted, the current year is used. (optional) Note: If the year is outside of the range for Unix timestamps (before 1970 or after 2037), this function will generate a warning. The easter_days() function can be used instead of easter_date() to calculate Easter for years which fall outside the range.


It shows the basic use of this function.

PHP Source Code

  1. <?php
  2. echo(easter_date());//no date format
  3. echo"<br />";
  4. echo(date("M-d-Y", easter_date(2000)));//year of 2000
  5. echo"<br />";
  6. echo(date("M-d-Y", easter_date(2001)));//year of 2001
  7. echo"<br />";
  8. echo(date("M-d-Y", easter_date(2002)));//year of 2002
  9. ?>
The complete code.
  1. <!DOCTYPE html>
  2. <title>PHP easter_date()</title>
  3. </head>
  5. <?php
  6. echo(easter_date());//no date format
  7. echo"<br />";
  8. echo(date("M-d-Y", easter_date(2000)));//year of 2000
  9. echo"<br />";
  10. echo(date("M-d-Y", easter_date(2001)));//year of 2001
  11. echo"<br />";
  12. echo(date("M-d-Y", easter_date(2002)));//year of 2002
  13. ?>
  15. </body>
  16. </html>
This is the output of the codes above.
resultHope that this article will help you a lot. So what can you say about this article? Share your thoughts in the comment section below or email me at [email protected]. Practice Coding. Thank you very much.

Add new comment