PHPackages                             gpnalin/module-date-time - 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. gpnalin/module-date-time

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

gpnalin/module-date-time
========================

N/A

1.0.2(1y ago)04OSL-3.0PHPPHP ~8.1.0||~8.2.0||~8.3.0

Since Aug 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/gpnalin/module-date-time)[ Packagist](https://packagist.org/packages/gpnalin/module-date-time)[ RSS](/packages/gpnalin-module-date-time/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Aligent DateTime API
====================

[](#aligent-datetime-api)

Overview
--------

[](#overview)

The Aligent DateTime API is a Magento 2 module that provides functionality to calculate the difference between two dates. It supports various calculation types and can be accessed via both REST API and GraphQL.

Features
--------

[](#features)

- Calculate the difference between two dates in:
    - `days`: Calculate the total number of days
    - `weekdays`: Calculate the number of weekdays (Monday to Friday)
    - `weeks`: Calculate the number of complete weeks
    - `hours`: Calculate the total number of hours
    - `minutes`: Calculate the total number of minutes
    - `seconds`: Calculate the total number of seconds
    - `years`: Calculate the number of years
- Support for standard datetime formats with timezone
- REST API endpoint
- GraphQL query
- Unit test and API/GraphQL functional testing

Installation
------------

[](#installation)

1. If you already have Magento instance setup, skip to #6.
2. Create your project directory then go into it: ```
    mkdir magento.test; cd $_;

    ```
3. Download the Docker Compose template: ```
    curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/template | bash

    ```
4. Download the version of Magento you want to use with: ```
    bin/download 2.4.7 community

    ```
5. Run the setup installer for Magento: ```
    bin/setup magento.test

    ```
6. Install the module: ```
    bin/composer require gpnalin/module-date-time

    # or clone the module to app/code/Aligent/DateTime

    mkdir -p app/code/Aligent;
    cd $_;
    git clone git@github.com:gpnalin/module-date-time.git DateTime;

    ```
7. Enable the module by running: ```
    bin/magento module:enable Aligent_DateTime

    ```
8. Run the Magento setup upgrade: ```
    bin/magento setup:upgrade

    ```
9. Compile Dependency Injection: ```
    bin/magento setup:di:compile

    ```
10. Clean the cache:

```
bin/magento cache:clean

```

Usage
-----

[](#usage)

### REST API

[](#rest-api)

#### Endpoint

[](#endpoint)

`POST /V1/datetime/calculate`

#### Parameters

[](#parameters)

- `startDate` (string): The start date in ISO 8601 format (e.g., "2023-01-01T00:00:00+00:00")
- `endDate` (string): The end date in ISO 8601 format (e.g., "2023-01-10T00:00:00+00:00")
- `calculationType` (string): The type of calculation to perform (days, weekdays, weeks, hours, minutes, seconds, years)

#### Example Request

[](#example-request)

```
POST /V1/datetime/calculate
Content-Type: application/json

{
  "startDate": "2023-01-01T00:00:00+00:00",
  "endDate": "2023-01-10T00:00:00+00:00",
  "calculationType": "days"
}
```

#### Example Response

[](#example-response)

```
{
    "result": 9
}
```

### GraphQL

[](#graphql)

#### Query

[](#query)

```
query DiffCalculatorQuery(
  $startDate: String!,
  $endDate: String!,
  $calculationType: CalculationType!
) {
    DiffCalculatorQuery(
    startDate: $startDate,
    endDate: $endDate,
    calculationType: $calculationType
  ) {
    result
  }
}
```

#### Variables

[](#variables)

```
{
  "startDate": "2023-01-01T00:00:00+00:00",
  "endDate": "2023-01-10T00:00:00+00:00",
  "calculationType": "days"
}
```

#### Example Response

[](#example-response-1)

```
{
  "data": {
    "DiffCalculatorQuery": {
      "result": 9
    }
  }
}
```

Error Handling
--------------

[](#error-handling)

Both the REST API and GraphQL query will return appropriate error messages if the input is invalid or if an unexpected error occurs during calculation.

Notes
-----

[](#notes)

- All dates should be provided in standard datetime formats with timezone information.
- If no timezone is specified, UTC is assumed.
- The `endDate` must be greater than or equal to the `startDate`.

Test Coverage
-------------

[](#test-coverage)

- Unit Test ```
    /usr/local/bin/php -dmemory_limit=-1 $(pwd)/vendor/bin/phpunit --bootstrap $(pwd)/dev/tests/unit/framework/bootstrap.php --configuration $(pwd)/dev/tests/unit/phpunit.xml.dist $(pwd)/vendor/gpnalin/module-date-time/Test/Unit/

    ```
- Web API Functional Test ```
    /usr/local/bin/php -dmemory_limit=-1 $(pwd)/vendor/bin/phpunit -c $(pwd)/dev/tests/api-functional/phpunit_rest.xml.dist $(pwd)/vendor/gpnalin/module-date-time/Test/Api/

    ```
- GraphQL Functional Test ```
    /usr/local/bin/php -dmemory_limit=-1 $(pwd)/vendor/bin/phpunit -c $(pwd)/dev/tests/api-functional/phpunit_graphql.xml.dist $(pwd)/vendor/gpnalin/module-date-time/Test/GraphQl/

    ```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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 ~0 days

Total

2

Last Release

630d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f60afb5fc22afd424febcc20318bda0312f7577d417ff8c46efa6baec5c2d02?d=identicon)[gpnalin](/maintainers/gpnalin)

### Embed Badge

![Health badge](/badges/gpnalin-module-date-time/health.svg)

```
[![Health](https://phpackages.com/badges/gpnalin-module-date-time/health.svg)](https://phpackages.com/packages/gpnalin-module-date-time)
```

###  Alternatives

[yireo/magento2-webp2

Magento 2 module to add WebP support to the Magento frontend

2091.2M7](/packages/yireo-magento2-webp2)[tig/postnl-magento2

TIG Magento 2 PostNL extension

58544.2k4](/packages/tig-postnl-magento2)[lillik/magento2-price-decimal

Magento 2 Price Decimal Precision

111147.5k](/packages/lillik-magento2-price-decimal)[nosto/module-nostotagging

Increase your conversion rate and average order value by delivering your customers personalized product recommendations throughout their shopping journey.

27659.1k4](/packages/nosto-module-nostotagging)[magepal/magento2-customeraccountlinksmanager

Customer Account Links Manager for Magento2 allows you to quickly and easily remove unwanted links from customer account dashboard

4084.9k](/packages/magepal-magento2-customeraccountlinksmanager)[doofinder/doofinder-magento2

Doofinder module for Magento 2

13204.0k1](/packages/doofinder-doofinder-magento2)

PHPackages © 2026

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