How to convert Julian calendar dates to Julian day counts in PHP calendar

醉折花枝作酒筹
Release: 2023-03-11 20:30:01
Original
1841 people have browsed it

In php, there is a method to convert the date of the Julian calendar into a Julian day count. Today we will introduce this algorithm. Friends in need can refer to it.

We must have learned the PHP calendar extension before, but do you know that there is actually a very interesting function in the calendar extension, which is the juliantojd() function. This function can convert a date in the Julian calendar into a Julian day count. Isn't it amazing?

We will definitely have a question before learning this function, that is, what is the Julian calendar? I believe many people don’t know that the Julian calendar was actually developed by Julius Caesar (also translated as Gaius Julius Caesar, Gaius Julius Caesar), the dictator of the Roman Republic. A calendar that replaced the old Roman calendar and was implemented on January 1, 45 BC, after Julius Caesar, Julius Caesar, etc.) adopted the calculations of Sosichenius, a mathematician and astronomer in Alexandria, Egypt.

Use this

Unix timestamp conversion tool

to get the results directly, and you no longer have to worry about wrong results. Now that we know the Julian calendar, let us take a look at the juliantojd() function.

Syntax

juliantojd(month,day,year);
Copy after login
month, specified as month, the month ranges from 1 (January) to 12 (December)

day, specified as day , the date range is from 1 to 31

year, specified as year, and the year range is from -4713 to 9999 (reasonable years in the Julian calendar are 4713 B.C. to 9999 A.D.)

Return value: Specifies the number of julian days corresponding to the date in the julian calendar.

Example - Convert a Julian calendar date to a Julian calendar date, and then convert back to a Julian calendar date

<?php
$jd=juliantojd(7,07,1972);
echo $jd . "<br>";
echo jdtojulian($jd);//jdtojulian函数将儒略日计数的日期转换为儒略历法
?>
Copy after login

Result

2441519
7/7/1972
Copy after login

Extended information

In the Julian calendar, a year is divided into 12 months, with big and small months alternating; there is a leap every four years, and there are 365 days in an ordinary year. , 366 days in a leap year means adding a leap day at the end of February of that year, and the average annual length is 365.25 days. As the accumulated errors in actual use became larger and larger over time, in 1582 Pope Gregory XIII (also translated as Gregory XIII) promulgated and implemented a calendar based on the Julian calendar that was improved. The Gregorian calendar is the Gregorian calendar.

Recommendation:

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

The above is the detailed content of How to convert Julian calendar dates to Julian day counts in PHP calendar. 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
Popular Tutorials
More>
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!