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

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

hilalahmad/date-time
====================

Creating a PHP package for date and time manipulation can be highly useful, especially when dealing with various date-related functionalities. Let's call this package DateTime.

1.0.0(2y ago)05MITPHPPHP ^7.2 | ^8.0

Since Nov 20Pushed 2y ago1 watchersCompare

[ Source](https://github.com/hilalahmad0101/php-date-time)[ Packagist](https://packagist.org/packages/hilalahmad/date-time)[ RSS](/packages/hilalahmad-date-time/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

date-time PHP Package
=====================

[](#date-time-php-package)

 *Creating a PHP package for date and time manipulation can be highly useful, especially when dealing with various date-related functionalities. Let's call this package "DateTime."*

 [ ![GitHub issues](https://camo.githubusercontent.com/50239def235eab1da7f34b0207bad1750a3b81448c7a50631e190e8c8b52ab53/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f68696c616c61686d6164303130312f7068702d646174652d74696d65) ](https://github.com/hilalahmad0101/php-date-time/issues) [ ![GitHub stars](https://camo.githubusercontent.com/c9c1376244280004f6b03b1bc5b71bed845d4ad54cf876b78552b2714a1d2f24/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f68696c616c61686d6164303130312f7068702d646174652d74696d65) ](https://github.com/hilalahmad0101/php-date-time/stargazers) [ ![Total Downloads](https://camo.githubusercontent.com/c6cc635640535960c3ebbcfc14f2eb05a6266c9577d781ff33ee59fe5cd089ed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68696c616c61686d6164303130312f7068702d646174652d74696d65) ](https://packagist.org/packages/hilalahmad0101/php-date-time) [ ![License](https://camo.githubusercontent.com/fac77596f8744dd66ed011783072ee407f7c9e7d3e6a2a677c92a482da19ee3b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f68696c616c61686d6164303130312f7068702d646174652d74696d65) ](https://github.com/hilalahmad0101/php-date-time/blob/main/LICENSE)

###### 20+ function you can use it in your project make your project with better data and time.

[](#20-function-you-can-use-it-in-your-project-make-your-project-with-better-data-and-time)

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

[](#installation)

You can install this package using Composer, a popular PHP package manager:

```
composer require hilalahmad/date-time
```

Basic Usage
-----------

[](#basic-usage)

Here's an example of how to use the date and time package:

```
use Hilalahmad\DateAndTime\DateAndTime;

// Format the current date
$formattedDate = DateAndTime::formatDate('Y-m-d H:i:s', '2020234');
echo "Formatted Date: $formattedDate\n";

// Calculate the difference between two dates
$date1 = '2022-01-01 00:00:00';
$date2 = '2022-01-29 00:00:00';
$daysDifference = DateAndTime::dateDifference($date1, $date2, 'days');
echo "Days Difference: $daysDifference\n";

// Parse a date string
$dateString = '2022-12-31 23:59:59';
$parsedDate = DateAndTime::parseDate($dateString);
echo "Parsed Date: " . $parsedDate->format('Y-m-d H:i:s') . "\n";

// Get the current timestamp
$currentTimestamp = DateAndTime::getCurrentTimestamp();
echo "Current Timestamp: $currentTimestamp\n";

$futureDate = '2023-12-31 12:00:00';
$pastDate = '2020-01-01 00:00:00';

$futureCheck = DateAndTime::isInFuture($futureDate);
$pastCheck = DateAndTime::isInPast($pastDate);

echo "Is $futureDate in the future? " . ($futureCheck ? 'Yes' : 'No') . "\n";
echo "Is $pastDate in the past? " . ($pastCheck ? 'Yes' : 'No') . "\n";

$newDate = DateAndTime::addYears('2022-01-01 00:00:00', 5);
echo "Date after adding 5 years: $newDate\n";

$previousMonth = DateAndTime::subtractMonths('2022-08-15 12:00:00', 1);
echo "Date after subtracting 1 month: $previousMonth\n";

$dayOfWeek = DateAndTime::getDayOfWeek('2022-11-20 00:00:00');
echo "Day of the week: $dayOfWeek\n";

$age = DateAndTime::calculateAge('1990-05-15');
echo "Age: $age\n";

$overlap = DateAndTime::doDateRangesOverlap('2022-01-01', '2022-01-10', '2022-01-05', '2022-01-15');
echo "Do date ranges overlap? " . ($overlap ? 'Yes' : 'No') . "\n";

$timestamp = strtotime('2023-11-16 16:34:56');
$relativeTime = DateAndTime::relativeTime($timestamp);
echo "Relative Time: $relativeTime\n";

$weekNumber = DateAndTime::getCurrentWeekNumber();
echo "Current Week Number: $weekNumber\n";

$isCurrentMonth = DateAndTime::isCurrentMonth(2022, 11);
echo "Is November 2022 the current month? " . ($isCurrentMonth ? 'Yes' : 'No') . "\n";

$isWeekend = DateAndTime::isWeekend('2022-11-20');
echo "Is November 20, 2022, a weekend? " . ($isWeekend ? 'Yes' : 'No') . "\n";

$quarter = DateAndTime::getQuarter('2022-11-15');
echo "Quarter of November 15, 2022: $quarter\n";

$isFutureYear = DateAndTime::isFutureYear(2023);
echo "Is 2023 a future year? " . ($isFutureYear ? 'Yes' : 'No') . "\n";

$isToday = DateAndTime::isToday('2022-11-15');
echo "Is today November 15, 2022? " . ($isToday ? 'Yes' : 'No') . "\n";

$nextWeekdays = DateAndTime::getNextWeekdays('2022-11-15', 5);
echo "Next 5 weekdays from November 15, 2022: " . implode(', ', $nextWeekdays) . "\n";

$lastDayOfMonth = DateAndTime::getLastDayOfCurrentMonth();
echo "Last day of the current month: $lastDayOfMonth\n";

$isMorning = DateAndTime::isInMorning('2022-11-15 08:30:00');
echo "Is 8:30 AM on November 15, 2022, in the morning? " . ($isMorning ? 'Yes' : 'No') . "\n";

$nextMonths = DateAndTime::getNextMonths('2022-11-15', 3);
echo "Next 3 months from November 15, 2022: " . implode(', ', $nextMonths) . "\n";

$daysDifference = DateAndTime::getDaysDifference('2022-01-01', '2023-01-01');
echo "Days Difference: $daysDifference\n";

$leapYearCheck = DateAndTime::isLeapYear(2024);
echo "Is 2024 a leap year? " . ($leapYearCheck ? 'Yes' : 'No') . "\n";

$monthRange = DateAndTime::getMonthRange(2022, 8);
echo "August 2022 Range: {$monthRange['first_day']} to {$monthRange['last_day']}\n";
```

Contribution
------------

[](#contribution)

If you'd like to contribute to this package or report issues, please check the [ Github repo](https://github.com/fullstack124/php-date-time/issues) for more details.

License
-------

[](#license)

This package is open-source and is licensed under the MIT License.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Unknown

Total

1

Last Release

901d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8130aa2a0353184f190feb106a6c11f57afa8872ec9e15e75b782d9e03dc5bde?d=identicon)[hilal ahmad](/maintainers/hilal%20ahmad)

---

Top Contributors

[![hilalahmad0101](https://avatars.githubusercontent.com/u/115874624?v=4)](https://github.com/hilalahmad0101 "hilalahmad0101 (1 commits)")

---

Tags

data-timedateandtimedatetimeformat

### Embed Badge

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

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

PHPackages © 2026

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