PHP code example of zachweix / php-zmanim

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

    

zachweix / php-zmanim example snippets


use PhpZmanim\Zman;
use PhpZmanim\JewishDate;

// Zmanim for a date and location
$zman = Zman::create(2019, 2, 22, 40.0721087, -74.2400243, 39.57, 'America/New_York');
$zman->getSunrise()->format('Y-m-d\TH:i:sP');  // 2019-02-22T06:39:45-05:00
$zman->getTzais72Minutes()->format('Y-m-d\TH:i:sP');   // 2019-02-22T18:52:39-05:00

// The Jewish calendar
$jewishDate = JewishDate::createFromDate(2023, 9, 30);  // from a Gregorian date
$jewishDate = JewishDate::create(5784, 7, 15);          // or from a Jewish date
$jewishDate->isSuccos();       // true
$jewishDate->isRoshHashana();  // false

// Formatting, in English or Hebrew
$jewishDate->format()->english()->yomTov();  // Succos
$jewishDate->format()->hebrew()->date();      // ט״ו תשרי תשפ״ד


PhpZmanim\Zman;
use PhpZmanim\JewishDate;

$zman = Zman::create(2019, 2, 22, 40.0721087, -74.2400243, 39.57, 'America/New_York');

$zman->getSunrise();          // a Carbon instance
$zman->getSunset();
$zman->getSofZmanShmaGRA();
$zman->getChatzosHayom();
$zman->getPlagHaminchaGRA();
$zman->getTzais72Minutes();

$zman->getSunset()->format('g:i A');   // 5:41 PM
$zman->getSunset()->toIso8601String();

use PhpZmanim\Calculator\MeeusCalculator;

$zman = Zman::create(2019, 2, 22, 40.0721087, -74.2400243, 39.57, 'America/New_York', MeeusCalculator::create());
// or on an existing object:
$zman->setAstronomicalCalculator(MeeusCalculator::create());

$jewishDate = JewishDate::createFromDate(2023, 9, 30);  // Gregorian year, month, day
$jewishDate = JewishDate::create(5784, 7, 15);          // Jewish year, month, day

$jewishDate->isSuccos();          // true
$jewishDate->getJewishYear();     // 5784
$jewishDate->getDafYomiBavli();   // a Daf value object

$jewishDate = JewishDate::create(5784, 7, 15);

$jewishDate->format()->english()->date();     // 15 Tishrei, 5784
$jewishDate->format()->hebrew()->date();       // ט״ו תשרי תשפ״ד
$jewishDate->format()->english()->yomTov();    // Succos
$jewishDate->format()->hebrew()->yomTov();      // סוכות

// Daf yomi
JewishDate::createFromDate(2024, 5, 30)->format()->english()->dafYomiBavli();  // Bava Metzia 92

// The kviah (year type) is Hebrew only
JewishDate::create(5784, 7, 1)->format()->hebrew()->kviah();  // זחג

$ composer