PHP code example of mjaschen / astrotools

1. Go to this page and download the library: Download mjaschen/astrotools 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/ */

    

mjaschen / astrotools example snippets


use Astrotools\Time\JulianDay;

$timestamp = new \DateTime('2015-02-25 12:01:36', new \DateTimeZone('Europe/Berlin'));
$jd = JulianDay::fromDateTime($timestamp);

echo $jd->getValue();

use Astrotools\Time\JulianDay;

$jd = new JulianDay(2451545.0);

var_dump($jd->getDateTime());

use Astrotools\Time\SiderealTime;

$dt = new \DateTime('2007-12-25 00:00:00', new \DateTimeZone('UTC'));
$st = new SiderealTime($dt);

echo $st->getSiderealTime();

use Astrotools\Time\SiderealTime;

$dt = new \DateTime('2007-12-25 20:00:00', new \DateTimeZone('UTC'));
$st = new SiderealTime($dt);

echo $st->getLocalSiderealTime(13.5);

use Astrotools\Helper\Time;

$time = Time::fromTime(6, 42, 23.1337);

echo $time->getValue();

use Astrotools\Helper\Time;

$time = new Time(6.7064260278);

printf('%02d:%02d:%02.4f', $time->getHour(), $time->getMinute(), $time->getSecond());

use Astrotools\Helper\Time;

$time = Time::fromTime(6, 42, 23.1337);

echo $time->getHourAngle() . PHP_EOL;

echo Time::fromHourAngle(275)->getValue();

use Astrotools\Time\DateOfEaster;

$doe = new DateOfEaster(2000);

echo $doe->getDate()->format('Y-m-d');



use Astrotools\Time\DeltaT\PolynomialExpression;

$deltaT = new PolynomialExpression();

echo $deltaT->getDeltaT(2016.125);