PHP code example of abbadon1334 / sun-position-spa-php

1. Go to this page and download the library: Download abbadon1334/sun-position-spa-php 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/ */

    

abbadon1334 / sun-position-spa-php example snippets


$SD = new SolarData\SolarData();

/* ARGS : observer latitude, observer longitude, observer altitude */
$SD->setObserverPosition(39.742476,-105.1786,1830.14);

/* ARGS : Observer Date : Year, Month, Day */
$SD->setObserverDate(2003, 10, 17);

/* ARGS : Observer Time : Hours, Minutes, Seconds */
$SD->setObserverTime(12, 30,30);

/* ARGS : difference in seconds between the Earth rotation time and the Terrestrial Time (TT) */
$SD->setDeltaTime(67);
/* ARGS : Observer Timezone */
$SD->setObserverTimezone(-7);

/* ARGS : Observer mean pressure in Millibar */
$SD->object->setObserverAtmosphericPressure(820);

/* ARGS : Observer mean temperature in Celsius */
$SD->object->setObserverAtmosphericTemperature(11.0);

/* calculate sun position */
$SunPosition = $SD->calculate();

$SD = new SolarData\SolarData();

/* ARGS : observer latitude, observer longitude, observer altitude */
$SD->setObserverPosition(39.742476,-105.1786,1830.14);

/* ARGS : Observer Date : Year, Month, Day */
$SD->setObserverDate(2003, 10, 17);

/* ARGS : Observer Time : Hours, Minutes, Seconds */
$SD->setObserverTime(12, 30,30);

/* ARGS : difference in seconds between the Earth rotation time and the Terrestrial Time (TT) */
$SD->setDeltaTime(67);
/* ARGS : Observer Timezone */
$SD->setObserverTimezone(-7);

/* ARGS : Observer mean pressure in Millibar */
$SD->object->setObserverAtmosphericPressure(820);

/* ARGS : Observer mean temperature in Celsius */
$SD->object->setObserverAtmosphericTemperature(11.0);

/* calculate sun position */
$SunPosition = $SD->calculate();

echo $SunPosition->H°;


$SD = new SolarData\SolarData();

/* ARGS : observer latitude, observer longitude, observer altitude */
$SD->setObserverPosition(39.742476,-105.1786,1830.14);

/* ARGS : Observer Date : Year, Month, Day */
$SD->setObserverDate(2003, 10, 17);

/* ARGS : Observer Time : Hours, Minutes, Seconds */
$SD->setObserverTime(12, 30,30);

/* ARGS : difference in seconds between the Earth rotation time and the Terrestrial Time (TT) */
$SD->setDeltaTime(67);
/* ARGS : Observer Timezone */
$SD->setObserverTimezone(-7);

/* ARGS : Observer mean pressure in Millibar */
$SD->object->setObserverAtmosphericPressure(820);

/* ARGS : Observer mean temperature in Celsius */
$SD->object->setObserverAtmosphericTemperature(11.0);

/* calculate sun position and calculate sun rise transit set angles 
ARGS : true = call ->calculate()
*/
$SunPosition = $SD->calculateSunRiseTransitSet(true);

$SunRiseDayFraction = $SunPosition->DayFractionSunrise;
$TransitDayFraction = $SunPosition->DayFractionTransit;
$SunsetDayFraction  = $SunPosition->DayFractionSunset;



$SD = new SolarData\SolarData();

/* ARGS : observer latitude, observer longitude, observer altitude */
$SD->setObserverPosition(39.742476,-105.1786,1830.14);

/* ARGS : Observer Date : Year, Month, Day */
$SD->setObserverDate(2003, 10, 17);

/* ARGS : Observer Time : Hours, Minutes, Seconds */
$SD->setObserverTime(12, 30,30);

/* ARGS : difference in seconds between the Earth rotation time and the Terrestrial Time (TT) */
$SD->setDeltaTime(67);
/* ARGS : Observer Timezone */
$SD->setObserverTimezone(-7);

/* ARGS : Observer mean pressure in Millibar */
$SD->object->setObserverAtmosphericPressure(820);

/* ARGS : Observer mean temperature in Celsius */
$SD->object->setObserverAtmosphericTemperature(11.0);