PHPackages                             fadyreda99/laravel-date-helper - 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. fadyreda99/laravel-date-helper

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

fadyreda99/laravel-date-helper
==============================

Flexible date-to-MySQL-date parser (Arabic digits/months + many formats) for Laravel

v1.0.3(5mo ago)05MITPHPPHP &gt;=8.0

Since Dec 2Pushed 5mo agoCompare

[ Source](https://github.com/fadyreda99/laravel-date-helper)[ Packagist](https://packagist.org/packages/fadyreda99/laravel-date-helper)[ RSS](/packages/fadyreda99-laravel-date-helper/feed)WikiDiscussions master Synced 1mo ago

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

DateHelper – Smart, Flexible Date Normalization for Laravel
===========================================================

[](#datehelper--smart-flexible-date-normalization-for-laravel)

A lightweight Laravel package that converts any human-written date string — including Arabic digits, Arabic month names, timestamps, and messy formats — into a clean MySQL-compatible date (`Y-m-d`).

This package solves a common real-world problem:

> Users enter dates in many different formats.
> Your backend needs one consistent format.

DateHelper intelligently detects, normalizes, and validates dates coming from forms, mobile apps, imports, or mixed Arabic/English inputs.

---

🌟 Features
----------

[](#-features)

- Converts almost any date format into `Y-m-d`
- Full support for Arabic digits (`٠١٢٣٤٥٦٧٨٩`)
- Full support for Persian digits (`۰۱۲۳۴۵۶۷۸۹`)
- Arabic month names support (مارس, أكتوبر, أغسطس …)
- Automatic timestamp handling (seconds &amp; milliseconds)
- Cleans noise (ordinals, commas, NBSP, time parts)
- Safe fallback using Carbon natural-language parsing
- Year-range validation to avoid parsing Hijri years incorrectly
- Graceful error handling (`null` on failure)
- No warnings, no exceptions thrown

---

🚀 Installation
--------------

[](#-installation)

```
composer require fadyreda99/laravel-date-helper
```

Laravel automatically discovers the service provider.

---

🧠 Usage
-------

[](#-usage)

### 1️⃣ Static Usage

[](#1️⃣-static-usage)

```
use Fadyreda99\DateHelper\DateHelper;

$date = DateHelper::toMysqlDate('٠٣/٠٤/٢٠٢٤');
// "2024-04-03"
```

---

### 3️⃣ Dependency Injection

[](#3️⃣-dependency-injection)

```
use Fadyreda99\DateHelper\DateHelper;

class MyController
{
    public function store(DateHelper $dates)
    {
        $clean = $dates->toMysqlDate('March 4, 2024');
        // "2024-03-04"
    }
}
```

---

🔍 Supported Formats
-------------------

[](#-supported-formats)

### Numeric:

[](#numeric)

- Y-m-d
- Y/m/d
- Y.m.d
- Ymd
- d-m-Y
- d/m/Y
- d.m.Y
- dmY
- m-d-Y
- m/d/Y
- m.d.Y

### Textual:

[](#textual)

- F j, Y
- F d, Y
- M j, Y
- M d, Y
- j F Y
- d F Y
- j M Y
- d M Y

### Mixed:

[](#mixed)

- d M Y
- M d Y
- d-M-Y
- d.M.Y

### Natural Language Fallback:

[](#natural-language-fallback)

- "today"
- "yesterday"
- "tomorrow"
- "next week"
- "next month"
- "last week"
- "last month"
- "in 2 days"
- "in 3 weeks"
- "-1 day"
- "+1 day"
- "+2 months"
- "last friday"
- "next tuesday"

---

🌍 Arabic &amp; Persian Support
------------------------------

[](#-arabic--persian-support)

### Arabic Digit Conversion

[](#arabic-digit-conversion)

`٠٣/٠٤/٢٠٢٤` → `03/04/2024`

### Arabic Month Names

[](#arabic-month-names)

- مارس → March
- أكتوبر → October
- اغسطس → August

### Persian Digits

[](#persian-digits)

`۲۰۲۴-۰۴-۰۳` → `2024-04-03`

---

🕒 Timestamp Support
-------------------

[](#-timestamp-support)

Supports:

- 10-digit Unix timestamps
- 13+ digit millisecond timestamps

Example:

```
DateHelper::toMysqlDate('1609459200000');
// "2021-01-01"
```

---

⚙️ Year Validation
------------------

[](#️-year-validation)

Accepted year range:

1900 → (current year + 5)

Prevents treating Hijri-like dates such as:

`1445-01-01`

as Gregorian year 1445.

---

🚫 Error Handling
----------------

[](#-error-handling)

If the date cannot be parsed, the function returns:

```
null
```

- No exceptions
- No warnings
- Safe for forms, DTOs, models, imports

---

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome!
If you find a missing format, edge case, or improvement — please open an issue or PR.

---

📄 License
---------

[](#-license)

This package is open-source under the MIT License.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance71

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

Total

4

Last Release

161d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a531d35d2b3f9c22fac568e8955acb2b8f7933bce328e7f63139cad3a7288b5?d=identicon)[fadyreda99](/maintainers/fadyreda99)

---

Top Contributors

[![fadyreda99](https://avatars.githubusercontent.com/u/130838390?v=4)](https://github.com/fadyreda99 "fadyreda99 (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fadyreda99-laravel-date-helper/health.svg)

```
[![Health](https://phpackages.com/badges/fadyreda99-laravel-date-helper/health.svg)](https://phpackages.com/packages/fadyreda99-laravel-date-helper)
```

###  Alternatives

[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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