PHPackages                             jono20201/input-to-date - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. jono20201/input-to-date

AbandonedArchivedLibrary[Validation &amp; Sanitization](/categories/validation)

jono20201/input-to-date
=======================

A small PHP library that assists with converting your user input into a Carbon object

1.3(9y ago)110.1kMITPHP

Since Oct 26Pushed 9y ago2 watchersCompare

[ Source](https://github.com/Jono20201/input-to-date)[ Packagist](https://packagist.org/packages/jono20201/input-to-date)[ RSS](/packages/jono20201-input-to-date/feed)WikiDiscussions master Synced 4w ago

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

InputToDate
===========

[](#inputtodate)

This is a really simple library to convert user input to a Carbon object without having to worry about the possible exceptions that maybe thrown with bad or empty input.

If you're using a framework (such as Laravel) you should still validate user input if you want to send them nice errors about invalid input.

Features
--------

[](#features)

- Parse user input to a Carbon object.
- Throw an Exception or return a default upon error/empty input.
- Fluent API

Usage
-----

[](#usage)

The following example would return a Carbon object with the correct date.

```
    $user_input = '01/01/2016 09:30:30'
    $date = InputToDate::create('d/m/Y H:i:s')
                        ->convert($user_input);
```

The following example has incorrect input, and will return `null` as we have asked it to by running the `setReturnNullOnFailure()` method.

```
    $user_input = '01/01/2016 09:30:30'
    $date = InputToDate::create('d/m/Y')
                        ->setReturnNullOnFailure()
                        ->convert($user_input);
```

The following example will return this current time as its incorrect, but as have asked for a default of `Carbon::now()`.

```
    $user_input = '01/01/2016 09:30:30'
    $date = InputToDate::create('d/m/Y')
                        ->setDefault(Carbon::now())
                        ->convert($user_input);
```

The following will throw an `InvalidArgumentException` exception as the input is incorrect and we have not set any other default. You can also explicitly add the `throwException()`method.

```
    $user_input = '01/01/2016 09:30:30'
    $date = InputToDate::create('d/m/Y')
                        ->convert($user_input);
```

Contribute
----------

[](#contribute)

Pull requests are more than welcome.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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

3534d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2374192?v=4)[Jonathan Martin](/maintainers/Jono20201)[@Jono20201](https://github.com/Jono20201)

---

Top Contributors

[![Jono20201](https://avatars.githubusercontent.com/u/2374192?v=4)](https://github.com/Jono20201 "Jono20201 (10 commits)")

---

Tags

datevalidateparseinput

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jono20201-input-to-date/health.svg)

```
[![Health](https://phpackages.com/badges/jono20201-input-to-date/health.svg)](https://phpackages.com/packages/jono20201-input-to-date)
```

###  Alternatives

[moment/moment

Parse, validate, manipulate, and display dates in JavaScript.

48.0k2.1M40](/packages/moment-moment)[timrwood/moment

Parse, validate, manipulate, and display dates in JavaScript.

48.0k18.4k](/packages/timrwood-moment)[fightbulc/moment

Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js

9683.3M12](/packages/fightbulc-moment)[waavi/sanitizer

Data sanitizer and Laravel 7 form requests with input sanitation.

433589.7k5](/packages/waavi-sanitizer)[elegantweb/sanitizer

Sanitization library for PHP and the Laravel framework.

1151.0M3](/packages/elegantweb-sanitizer)

PHPackages © 2026

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