DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • The LLM Advantage: Smarter Time Series Predictions With Less Effort
  • How to Enable Azure Databricks Lakehouse Monitoring Through Scripts
  • Leveraging Snowflake’s AI/ML Capabilities for Anomaly Detection
  • Overview of Classical Time Series Analysis: Techniques, Applications, and Models

Trending

  • Caching 101: Theory, Algorithms, Tools, and Best Practices
  • Understanding the Shift: Why Companies Are Migrating From MongoDB to Aerospike Database?
  • Modern Test Automation With AI (LLM) and Playwright MCP
  • The Perfection Trap: Rethinking Parkinson's Law for Modern Engineering Teams
  1. DZone
  2. Coding
  3. Languages
  4. Time Data Series: The Rest of the Story

Time Data Series: The Rest of the Story

Things I've learned about how the PHP Zmanim library helps calculate specific and special times that relate to Jewish life.

By 
Leon Adato user avatar
Leon Adato
·
Mar. 03, 25 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
3.2K Views

Join the DZone community and get the full member experience.

Join For Free

It’s been a while since I wrote about PHP Zmanim — the work I’ve done with it and the things I’ve learned while implementing it. But despite the delay, I always intended to continue the conversation. That’s what we’re doing today.

In my first post, I explained how to install and get started with the PHP Zmanim library. Then, in the next post, I dug into calculating more complex times and the real power of the tool — applying the most common Rabbinic opinions for various zmanim. I’m picking up where I left off with minimal overlap, so if you need to take a minute to get back up to speed,  I’ve linked to those previous posts.

The goal today is to explore uses of PHP Zmanim that move beyond the relatively straightforward use of the library. That includes:

  • Taking a standard time and adjusting it for synagogue specific use cases (“Mincha starts 25 minutes before Shkia each day”).
  • Using PHP Zmanim library functions and methods that provide non-time calculations — such as the weekly Torah Portion, the Hebrew date, and whether a specified date is a holiday (like Rosh Chodesh or Sukkot).

Acknowledgements

Once again, I need to begin by stating my gratitude to the folks who made all of this possible. Foremost among a long list of names is Zachary Weixelbaum, the maintainer of the PHP Zmanim library itself, and Eliyahu Hershfeld, creator of the Kosher Java library upon which PHP Zmanim is based.

A Quick Refresher

When we left off, we had a solid basic PHP script that:

  • Sets variables for the location (in latitude/longitude), along with the time zone and elevation.
  • Sets the date
  • Creates a php zmanim object from those variables
  • Uses the built-in methods to calculate the time for anything from sunrise to mincha to tzeit hakochavim

It looked like this:

PHP
 
<?php
require 'vendor/autoload.php';
use PhpZmanim\Zmanim;
use PhpZmanim\Calendar\ComplexZmanimCalendar;
use PhpZmanim\Geo\GeoLocation;
# Set variables:
$locname = "Beit Knesset Chochmat Shlomo, Beachwood, OH";
$lat = 41.4939407;
$long = -81.516709;
$elev = 0;
$tz = 'America/New_York';
$getyear = 2024;
$getday = 20;
$getmonth = 12;
$testzmanim = Zmanim::create($getyear, $getmonth, $getday, $locname, $lat, $long, $elev, $tz);
$sunrise = $testzmanim->sunrise;
echo "$sunrise\n";
?>


But the sunrise is just the beginning. Using any of the built-in calculations (which are described on the GitHub ReadMe page), you can pull a wide variety of times. For example, to get Mincha Gedola using a specific Rabbinic opinion, I could include:

PHP
 
$gedolah = $zmanim->minchaGedola16Point1Degrees


In the last blog, I also covered ways to use PHP Zmanim’s format method to make the output more readable:

PHP
 
$gedolah = $gedolah->format('g:i a');


“Salt to Taste” — Adjusting Times

For those who don’t spend a lot of time in synagogue (no blame, no shame, you’re still welcome here) it may not be obvious, but — despite the name of the zman — very few organizations pray Mincha (afternoon prayers) at Mincha Ketana, Mincha Gedola, or Plag haMincha.

In fact, a lot of the work with regard to calculating times has less to do with the straight “what time is Mincha Gedola?” and more with “how late in the day can we reasonably schedule Mincha so that everyone has time to get here after work; but not so late that nobody comes because they’ll miss dinner?”

If that’s too theoretical, allow me to share the logical jenga puzzle my synagogue considers when setting up the weekly schedule:

  • Friday night candle lighting: Shkia (sunset) minus 18 minutes
  • Summer Friday Mincha: Plag haMincha (using “plagHaminchaAteretTorah”) minus 20 minutes
  • Winter Friday Mincha: Shkia (sunset) minus 22 minutes
  • Saturday Mincha: Shkia minus 40 minutes
  • Saturday Ma’ariv: Shkia plus 50 minutes
  • Saturday end of Shabbat: Shkia plus 45 minutes
  • Weekday Mincha: find the earliest shkia for the week, then subtract 17 minutes

While all the other times I covered in earlier blogs still matter, hopefully, you are starting to realize that they matter less often than one might expect.

So, how do you take a time (like shkia/sunset) and then add or subtract minutes? We’ll start off with the same script we had before:

PHP
 
<?php
require 'vendor/autoload.php';
use PhpZmanim\Zmanim;
use PhpZmanim\Calendar\ComplexZmanimCalendar;
use PhpZmanim\Geo\GeoLocation;
# Set variables:
$locname = "Beit Knesset Chochmat Shlomo, Beachwood, OH";
$lat = 41.4939407;
$long = -81.516709;
$elev = 0;
$tz = 'America/New_York';
$getyear = 2024;
$getday = 20;
$getmonth = 12;
$testzmanim = Zmanim::create($getyear, $getmonth, $getday, $locname, $lat, $long, $elev, $tz);


To that, we’ll add the code to get sunset:

PHP
 
$sunset = $zmanim->sunset;


And then, we’ll subtract 18 minutes to get candle lighting time:

PHP
 
$candles = date('g:i a', strtotime($sunset . " -18 minutes"));


That’s right. You just use PHP's own string to time function. I’m sorry if I kept you in suspense. But it’s really just that easy.

What’s the Torah Portion? What’s the Hebrew Date? When Is Rosh Chodesh?

(…and other essential but vexing questions often asked in and around your synagogue.)

Along with date calculations, the KosherJava library (and therefore the PHP Zmanim library) has methods and functions to quickly provide information like the ones asked above.

The first thing to understand is that the PHP Zmanim object we’ve been working with so far has been a Zmanim object — an object that has a set of specific times for a particular date. For things involving the dates themselves, we instantiate a jewishCalendar object. The good news is that it’s much easier to create. All you need is the year, month, and day.

PHP
 
<?php
require 'vendor/autoload.php';
use PhpZmanim\Zmanim;
use PhpZmanim\Calendar\ComplexZmanimCalendar;
use PhpZmanim\Geo\GeoLocation;
# Set variables:
$getyear = 2024;
$getday = 21;
$getmonth = 09;
$jewishCalendar = Zmanim::jewishCalendar(Carbon::createFromDate($getyear, $getmonth, $getday));


We now have a jewishCalendar object to work with and can use methods similar to the ones we found for times. For example, presuming the date we selected was a Saturday, we can get the Torah portion:

PHP
 
$format = Zmanim::format();
$parshaeng = json_decode('"' . $format->formatParsha($jewishCalendar) . '"');


(Ignore the $format setting for now. We’ll dig into it in just a bit).

If you ran that code, $parshaeng would give you:

PHP
 
Parshas Ki Savo


You’ll notice we didn’t need to provide latitude, longitude, time zone, etc. I cannot stress enough that this capability alone – the ability to get dates, Torah portions, and more — makes the PHP Zmanim library useful all on its own, even without the time calculations. 

Can I Get That in Hebrew?

The Torah Portion? Of course! This is where the $format line comes in. 

First, an explanation of what it is: It’s a method that modifies objects like Zmanim and jewishCalendar, setting the display and output options. Setting Zmanim::format() without any other information defaults to English. But then you can tell the system you want Hebrew with this additional line:

PHP
 
$format->setHebrewFormat(true)


Now, if you run the same json_decode(‘”‘ . $format->formatParsha($jewishCalendar) . ‘”‘) line, you’d get:

Plain Text
 
כי תבוא


Putting it all together:

PHP
 
<?php
require 'vendor/autoload.php';
use PhpZmanim\Zmanim;
use PhpZmanim\Calendar\ComplexZmanimCalendar;
use PhpZmanim\Geo\GeoLocation;
# Set variables:
$getyear = 2024;
$getday = 21;
$getmonth = 09;
$jewishCalendar = Zmanim::jewishCalendar(Carbon::createFromDate($getyear, $getmonth, $getday));
$format = Zmanim::format();
$parshaeng = json_decode('"' . $format->formatParsha($jewishCalendar) . '"');
$format->setHebrewFormat(true);
$parshaheb = json_decode('"' . $format->formatParsha($jewishCalendar) . '"');
echo "$parshaheb - $parshaeng\n";


This would display: כי תבוא – Ki Savo.

What Day Is It?

More specifically, what HEBREW day is it?

Like the previous example, we start out with a jewishCalendar and a format object.

PHP
 
$jewishCalendar = Zmanim::jewishCalendar(Carbon::createFromDate($theyear, $themonth, $theday));
$format = Zmanim::format();


Then, we add the same line to set the format to Hebrew.

PHP
 
$format->setHebrewFormat(true);


And finally (and fairly simply), we ask for a straight calendar object output:

PHP
 
$zmandate = json_decode('"' . $format->format($jewishCalendar) . '"');


That’s literally all you need. The result is something like this:

Plain Text
 
17 Elul, 5784


Yes, even though we specified setHebrewFormat, it came out in English.

Can I Get That in Actual Hebrew?

In order to get the Hebrew date to show up fully in Hebrew — both words and letters — we invoke a slightly different method called, appropriately enough, HebrewDateFormatter. 

Presuming (once again) you set up your initial variables and created a jewishCalendar object, the code to output a Hebrew language date would be:

PHP
 
$hebformat = HebrewDateFormatter::create();
$hebformat->setHebrewFormat(true);
$hebdate = json_decode('"' . $hebformat->format($jewishCalendar) . '"');
print("Hebrew date: $hebdate\n");


Which would give you:

Plain Text
 
Hebrew date: י״ח אלול תשפ״ד


Is Today the Day?

Sometimes you need to check if a specific date is… well, a specific day like Rosh Chodesh (the new month) or part of a multi-day holiday (like Sukkot).

It turns out that the PHP Zmanim method makes this very simple. Presuming you’ve started off in the same way as the other examples, once you’ve set up the jewishCalendar object, it’s as simple as:

PHP
 
$jewishCalendar->isRoshHashana();
$jewishCalendar->isSuccos(); 


If the date matches the holiday, it will return “true,” and you can proceed with whatever logic or process you want, such as displaying the date (or not).

So What’s Next?

Believe it or not, there’s still more to cover. In the coming weeks Whenever I get to it, I’d like to cover ways to leverage the built-in astronomy functions for time calculations. Believe it or not, it can really matter in terms of having truly accurate times for things like the start and end of Shabbat and holidays, along with other observances.

In the meantime, if there’s something else you’d like to see me cover or if you have questions, corrections, or kudos, feel free to leave them in the comments below.

PHP Time series Data (computing)

Published at DZone with permission of Leon Adato. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • The LLM Advantage: Smarter Time Series Predictions With Less Effort
  • How to Enable Azure Databricks Lakehouse Monitoring Through Scripts
  • Leveraging Snowflake’s AI/ML Capabilities for Anomaly Detection
  • Overview of Classical Time Series Analysis: Techniques, Applications, and Models

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!