Download the PHP package adrian-cid/julian-converter without Composer
On this page you can find all versions of the php package adrian-cid/julian-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download adrian-cid/julian-converter
More information about adrian-cid/julian-converter
Files in adrian-cid/julian-converter
Package julian-converter
Short Description A PHP library for converting dates between the Gregorian calendar and Julian dates, with support for time precision down to seconds. Ideal for date manipulations, calendar conversions, and astronomical calculations.
License GPL-3.0
Homepage https://github.com/adrian-cid/julian-converter
Informations about the package julian-converter
Julian Date Converter
Julian Date Converter is a simple PHP library for converting dates between the Gregorian calendar and Julian dates, with precision down to seconds. It handles both conversions, taking into account the fractional day for exact time calculations.
Installation
You can install this package using Composer.
Requirements
- PHP 8.2 or higher.
Usage
1. Convert Gregorian Date to Julian Date
You can convert any DateTime
object from the Gregorian calendar to its equivalent Julian Date. The result will be a float
representing the Julian Date, including the fractional day for hours, minutes, and seconds.
2. Convert Julian Date to Gregorian Date
To convert a Julian Date back to the Gregorian calendar, use the convertJulianToGregorianDate()
method. The result will be a DateTime
object representing the equivalent Gregorian date and time.
Methods
convertGregorianToJulianDate(\DateTime $gregorian_date): float
Converts a DateTime
object (Gregorian date) into a Julian Date as a float
. The fractional part of the Julian Date reflects the time of day.
-
Parameters:
\DateTime $gregorian_date
: The date to be converted (Gregorian).
- Returns:
float
: The Julian Date with the fractional day included.
convertJulianToGregorianDate(float $julian_date): \DateTime
Converts a Julian Date to a DateTime
object (Gregorian date).
-
Parameters:
float $julian_date
: The Julian date to be converted.
- Returns:
\DateTime
: The equivalent Gregorian date and time.
License
This package is licensed under the GPL-3.0 License. See the LICENSE file for more details.