PHP code example of adrian-cid / julian-converter
1. Go to this page and download the library: Download adrian-cid/julian-converter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
adrian-cid / julian-converter example snippets
use AdrianCid\Calendar\JulianConverter;
// Create a DateTime object with the desired date and time.
$gregorian_date = new \DateTime('2024-10-02 15:30:00');
// Instantiate the converter and convert the Gregorian date to Julian date.
$converter = new JulianConverter();
$julian_date = $converter->convertGregorianToJulianDate($gregorian_date);
echo "The Julian Date is: " . $julian_date; // Output: The Julian Date is: 2460111.145833
use AdrianCid\Calendar\JulianConverter;
// Example Julian date.
$julian_date = 2460111.145833;
// Convert the Julian date back to a Gregorian DateTime object.
$gregorian_date = $converter->convertJulianToGregorianDate($julian_date);
echo "The Gregorian Date is: " . $gregorian_date->format('Y-m-d H:i:s');
// Output: The Gregorian Date is: 2024-10-02 15:30:00