⇧
vadnica-logo
Editor My Blog Password Manager Finance My Services About the Project Telegram O meni O meni

PHP Calendar

Building your own calendar using a PHP class is an excellent way to learn object-oriented programming. In the example below, you can review the complete code (HTML, Class, and CSS) that enables calendar rendering and event management.

EXAMPLE
RESULT
The result will be displayed here...

Advantages of Using the PHP Calendar Extension

PHP offers built-in support for working with calendars that goes far beyond simply displaying the current month. These functions are incredibly useful when you need to precisely calculate the number of days in any given month within your applications (accounting for leap years), determine the exact dates of movable holidays (such as Easter), or convert historical dates between various world calendar systems.

RESULT

PHP Calendar Quick Reference (Cheat Sheet)

The calendar extension includes features that simplify conversions between different calendar formats. It relies on the Julian Day Count, which is a simple continuous count of days since January 1, 4713 BC. To convert between different calendars, a date must first be converted into this neutral Julian Day Count, and then from that count into the calendar of your choice. Note: The Julian Day Count (a number) is not the same as the old Julian Calendar!

Function Name Description Example (Code for Simulator)
cal_days_in_month() Returns the number of days in a month for a specified year and calendar system. echo cal_days_in_month(CAL_GREGORIAN, 2, 2026); // February 2026
cal_from_jd() Converts a Julian Day Count into a detailed array containing information about a specific calendar date. print_r(cal_from_jd(2461168, CAL_GREGORIAN));
cal_info() Returns general information about a given calendar system (name, abbreviations, months). print_r(cal_info(CAL_GREGORIAN));
cal_to_jd() Converts a specific date within a chosen calendar system into a universal Julian Day Count. echo cal_to_jd(CAL_GREGORIAN, 6, 5, 2026);
easter_date() Returns the Unix timestamp for midnight on Easter Sunday for a specified year. echo date("d. m. Y", easter_date(2026));
easter_days() Returns the number of days after March 21 on which Easter falls for a specified year. echo easter_days(2026); // Number of days after March 21
frenchtojd() Converts a date from the French Revolutionary Calendar into a Julian Day Count. echo frenchtojd(9, 14, 3); // Month, day, year of the republic
gregoriantojd() Converts a standard Gregorian date into a Julian Day Count. echo gregoriantojd(6, 5, 2026); // Month, day, year
jddayofweek() Returns the day of the week based on a Julian Day Count (as an integer or a string). echo jddayofweek(2461168, 1); // 1 returns the textual name of the day
jdmonthname() Returns the month name for a specific calendar system based on a Julian Day Count. echo jdmonthname(2461168, 0); // 0 returns the Gregorian short name
jdtofrench() Converts a Julian Day Count into a date string based on the French Revolutionary Calendar. echo jdtofrench(2380650);
jdtogregorian() Converts a Julian Day Count back into a standard Gregorian date string (m/d/Y format). echo jdtogregorian(2461168);
jdtojewish() Converts a Julian Day Count into a Jewish calendar date string. echo jdtojewish(2461168);
jdtojulian() Converts a Julian Day Count into an old Julian calendar date string. echo jdtojulian(2461168);
jdtounix() Converts a Julian Day Count directly into a standard Unix timestamp (seconds since 1970). echo jdtounix(2461168);
jewishtojd() Converts a Jewish calendar date into a Julian Day Count. echo jewishtojd(9, 25, 5786); // Month, day, year
juliantojd() Converts an old Julian calendar date into a Julian Day Count. echo juliantojd(5, 23, 2026); // Month, day, year
unixtojd() Converts a standard Unix timestamp into a Julian Day Count. echo unixtojd(time());