Skip to content

PHP SDK

Install

composer require timenow/sdk

Quick Start

<?php

require_once 'vendor/autoload.php';

use TimeNow\TimeNowClient;

$client = new TimeNowClient('http://localhost:8090');

// Solar time for London
$result = $client->getSolarTime(51.5074, -0.1278);
echo $result->getSolarTime();           // "2026-04-14T11:49:23"
echo $result->getCivilSolarOffsetMin(); // -10.6

// Social jetlag
$jetlag = $client->getJetlag(39.47, 75.99);
echo $jetlag->getRiskLevel(); // "severe"

// Prayer times
$prayers = $client->getPrayerTimes(51.5074, -0.1278, convention: 'mwl');
echo $prayers->getDhuhr()->getCivil(); // "13:11"

Methods

Method Parameters Returns API endpoint
getSolarTime($lat, $lng, $utc = null) float, float, ?string SolarTimeResult GET /solar
getJetlag($lat, $lng) float, float JetlagResult GET /solar/jetlag
getPrayerTimes($lat, $lng, $date = null, $convention = 'mwl') float, float, ?string, ?string PrayerTimesResult GET /solar/prayer
getAlmanac($lat, $lng, $year = null) float, float, ?int AlmanacResult GET /solar/almanac
getDeviationMap($format = 'json') string array\|string GET /world/deviation-map
health() bool GET /health

Requirements

  • PHP 8.1+
  • ext-json
  • guzzlehttp/guzzle (installed automatically via Composer)