PHPackages                             invokemedia/parsetime - 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. invokemedia/parsetime

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

invokemedia/parsetime
=====================

This function can parse times in sentences that are in a range like 11 AM to 5 PM or 5:30 to 1:21.

1.2.0(9y ago)043MITPHP

Since Jul 28Pushed 9y ago7 watchersCompare

[ Source](https://github.com/invokemedia/parsetime)[ Packagist](https://packagist.org/packages/invokemedia/parsetime)[ Docs](https://github.com/invokemedia/parsetime)[ RSS](/packages/invokemedia-parsetime/feed)WikiDiscussions master Synced 3w ago

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

parse\_time
===========

[](#parse_time)

This package adds a single function called `parse_time` to your project. It does one thing. Parses times.

This function can parse times that are in a range like `11-5` or `11 AM to 5 PM`.

By passing a second argument (boolean) you can turn common words into their 24 hour equivalent.

For example: `11 AM - Midnight` would become `11 AM - 0:00`.

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

[](#installation)

Put a file named composer.json at the root of your project, containing your project dependencies:

```
{
    "require": {
        "invokemedia/parsetime": ">=1.0"
    }
}
```

Or use `composer require invokemedia/parsetime`

Usage
-----

[](#usage)

```
parse_time('11 AM - 5 PM');
parse_time('11:22 - 5:31');
parse_time('I will arrive at 1:22 and leave at 9:45');
parse_time('11 AM - Midnight', true); // would become 11 AM - 0:00

```

The function basically wraps up the [date\_parse](http://php.net/manual/en/function.date-parse.php) function. It will be run over the match for `11 AM` and `5 PM`.

Check out [the test file](https://github.com/invokemedia/parsetime/blob/master/tests/ParsetimeTest.php) for some of the examples.

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

[](#running-tests)

Go to the project root and run `phpunit`.

License
-------

[](#license)

**The MIT License**

Copyright (c) 2016 [Invoke Media](http://invokemedia.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

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

2

Last Release

3617d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/901374?v=4)[Invoke](/maintainers/invokemedia)[@invokemedia](https://github.com/invokemedia)

---

Top Contributors

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

---

Tags

timedateparsefunction

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/invokemedia-parsetime/health.svg)

```
[![Health](https://phpackages.com/badges/invokemedia-parsetime/health.svg)](https://phpackages.com/packages/invokemedia-parsetime)
```

###  Alternatives

[knplabs/knp-time-bundle

Making your dates and durations look sensible and descriptive

6239.3M51](/packages/knplabs-knp-time-bundle)[league/period

Time range API for PHP

7335.7M22](/packages/league-period)[brick/date-time

Date and time library

3623.6M94](/packages/brick-date-time)[aeon-php/calendar

PHP type safe, immutable calendar library

20410.2M16](/packages/aeon-php-calendar)[tplaner/when

Date/Calendar recursion library.

5261.1M7](/packages/tplaner-when)[florianv/business

DateTime calculations in business hours

360781.1k1](/packages/florianv-business)

PHPackages © 2026

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