PHPackages                             xrplwin/xrpl-ledgertime - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. xrplwin/xrpl-ledgertime

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

xrplwin/xrpl-ledgertime
=======================

This package will extract ledger index by giving date and time as input.

v1.0.1(3y ago)276MITPHPPHP ^8.1.0

Since Apr 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/XRPLWin/XRPL-LedgerTime)[ Packagist](https://packagist.org/packages/xrplwin/xrpl-ledgertime)[ Docs](https://github.com/XRPLWin)[ GitHub Sponsors](https://github.com/zgrguric)[ RSS](/packages/xrplwin-xrpl-ledgertime/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

[![main workflow](https://github.com/XRPLWin/XRPL-LedgerTime/actions/workflows/main.yml/badge.svg)](https://github.com/XRPLWin/XRPL-LedgerTime/actions/workflows/main.yml/badge.svg)[![GitHub license](https://camo.githubusercontent.com/6ad17e2f8573f877656fd84af97c6ff4ecc75c56485ba3de4d92a6062df88bcd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f5852504c57696e2f5852504c2d4c656467657254696d65)](https://github.com/XRPLWin/XRPL-LedgerTime/blob/main/LICENSE)[![Total Downloads](https://camo.githubusercontent.com/dedfe52bfe0dce5bebc8ce269f8950706af3c6642613fe263efe39a18c2d34de/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7872706c77696e2f7872706c2d6c656467657274696d652e7376673f7374796c653d666c6174)](https://packagist.org/packages/xrplwin/xrpl-ledgertime)

XRPL Ledger Time
================

[](#xrpl-ledger-time)

This package will extract ledger index by giving date and time as input.

Basically `2023-04-13 15:00:00 UTC` will give you `79077871`

Install
-------

[](#install)

```
composer require xrplwin/xrpl-ledgertime

```

Why?
----

[](#why)

There is no available XRPL API method to extract exact time of ledger. Say you want to query list of account transactions between Jan 1, 2022 08:00:00 and 12:00:00. For that query you need to provide in `account_tx` method `ledger_index_min` and `ledger_index_max`.

You can lookup local pre-synced database to get required ledger indexes and add them to query.

You can sync and store daily starting ledgers, hourly starting ledgers, etc. Periods you will sync depends of your business needs.

Fair use notice
---------------

[](#fair-use-notice)

**Always pre-sync times and store them in local or shared database!**

DO NOT use this script to query XRPLedger live in production site. This script extracts single ledger datetime by making multiple connections to XRPL Rest API. Use background sync job to pre-sync ledger times.

System time
-----------

[](#system-time)

A rippled server relies on maintaining the correct time. It is recommended that the your system synchronize time using the Network Time Protocol (NTP) with daemons such as ntpd or chrony.

Usage
-----

[](#usage)

Option 1 (datetime to ledgerindex)

```
use XRPLWin\XRPLLedgerTime\XRPLLedgerTimeSyncer;
use Carbon\Carbon;

$syncer = new XRPLLedgerTimeSyncer(); //init syncer

$datetime = Carbon::create(2023, 4, 13, 15, 0, 0, 'UTC'); //create Carbon datetime object
$ledgerIndex = $syncer->datetimeToLedgerIndex($datetime); //will return: 79077871
```

Option 2 (ledgerindex to datetime)

```
use XRPLWin\XRPLLedgerTime\XRPLLedgerTimeSyncer;

$syncer = new XRPLLedgerTimeSyncer(); //init syncer
$carbon = $syncer->ledgerIndexToCarbon(79077871);
```

Options overview:

```
$syncer = new XRPLLedgerTimeSyncer(
  [
    # Following values are defined by default, uncomment to override
    //'ledgerindex_low' => 0
  ],
  [
    # Following values are defined by default, uncomment to override
    # These options will be passed to \XRPLWin\XRPL\Client
    //'endpoint_fullhistory_uri' => 'https://xrplcluster.com'
  ]
);
```

Running tests
-------------

[](#running-tests)

Run all tests in "tests" directory.

```
composer test

```

or

```
./vendor/bin/phpunit --testdox

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~17 days

Total

2

Last Release

1107d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/02b0ccc19f65ae6ac53ec11a802ad35565047f862eeccde3a7291917920f9160?d=identicon)[xrplwin](/maintainers/xrplwin)

---

Top Contributors

[![zgrguric](https://avatars.githubusercontent.com/u/108837406?v=4)](https://github.com/zgrguric "zgrguric (14 commits)")

---

Tags

phpphp8xrplcomposerpackagedatetimetimeindexcarbonxrpledgerxrplrippledledgerindex

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xrplwin-xrpl-ledgertime/health.svg)

```
[![Health](https://phpackages.com/badges/xrplwin-xrpl-ledgertime/health.svg)](https://phpackages.com/packages/xrplwin-xrpl-ledgertime)
```

###  Alternatives

[rovangju/carbon-nbd

Carbon DateTime extension to calculate the "next business day"

2125.4k](/packages/rovangju-carbon-nbd)[wilianx7/php-recurring

PHP library to make getting dates easier when working with recurring tasks.

1045.0k](/packages/wilianx7-php-recurring)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
