PHPackages                             plumphp/plum-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. plumphp/plum-date

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

plumphp/plum-date
=================

PlumDate provides date and time converters for Plum.

v0.1(10y ago)113MITPHP

Since Oct 22Pushed 10y ago1 watchersCompare

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

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

 [![Plum](https://camo.githubusercontent.com/a81342cbfd6f64a484988488ad37bbd0e665d0f14f65ec655ae986097447bfb6/687474703a2f2f63646e2e666c6f7269616e2e65632f706c756d2d6c6f676f2e737667)](https://camo.githubusercontent.com/a81342cbfd6f64a484988488ad37bbd0e665d0f14f65ec655ae986097447bfb6/687474703a2f2f63646e2e666c6f7269616e2e65632f706c756d2d6c6f676f2e737667)
==================================================================================================================================================================================================================================================================================================================================================================

[](#----)

> PlumDate provides date and time converters for Plum. Plum is a data processing pipeline for PHP.

[![Build Status](https://camo.githubusercontent.com/d3789f101cdf19eeadbb0919261ec64395ceef20de155c0b0190a41639e5373a/68747470733a2f2f7472617669732d63692e6f72672f706c756d7068702f706c756d2d646174652e737667)](https://travis-ci.org/plumphp/plum-date)[![AppVeyor Build status](https://camo.githubusercontent.com/41c7437eafbd324445be4166dc88f510d001bcf077397b75869121c59f96920f/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f393138796c7730776833316b343338633f7376673d74727565)](https://ci.appveyor.com/project/florianeckerstorfer/plum-date)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f7d67918965b87b260a6d0e694619c48eced4540389d561bd03c5ca5ea346578/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f706c756d7068702f706c756d2d646174652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/plumphp/plum-date/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/8ba76589729d46b3cb5b492440de19dd95243e78d0a171a56e0a239e328225c6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f706c756d7068702f706c756d2d646174652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/plumphp/plum-date/?branch=master)[![StyleCI](https://camo.githubusercontent.com/89a24b80c0f5adfa026dc93dfa9f1061512fd49af86439fcdeb25661ef1d4642/68747470733a2f2f7374796c6563692e696f2f7265706f732f34343632303236312f736869656c64)](https://styleci.io/repos/44620261)

Developed by [Florian Eckerstorfer](https://florian.ec) in Vienna, Europe.

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

[](#installation)

You can install PlumDate using [Composer](http://getcomposer.org).

```
$ composer require plumphp/plum-date
```

Usage
-----

[](#usage)

Please refer to the [Plum documentation](https://github.com/plumphp/plum/blob/master/docs/index.md) for more information.

Currently PlumDate contains converters to convert strings and timestamps into `DateTime` objects and to convert `DateTime` objects into strings and timestamps and filters to detect whether a date is before or after a certain point in time.

### Overview

[](#overview)

**Converters**

- [`DateTimeToStringConverter`](#DateTimeToStringConverter)
- [`DateTimeToTimestampConverter`](#DateTimeToTimestampConverter)
- [`StringToDateTimeConverter`](#StringToDateTimeConverter)
- [`TimestampToDateTimeConverter`](#TimestampToDateTimeConverter)

**Filters**

- [`AfterFilter`](#afterfilter)
- [`BeforeFilter`](#beforefilter)
- [`RangeFilter`](#rangefilter)

### `DateTimeToStringConverter`

[](#datetimetostringconverter)

`Plum\PlumDate\DateTimeToStringConverter` converts a `DateTime` object into a string. The format of the string has to be passed to the constructor.

```
use Plum\PlumDate\DateTimeToStringConverter;

$converter = new DateTimeToStringConverter('y-m-d H:i:s');
$converter->convert(new DateTime()); // -> e.g., "2015-10-21 19:28:00"
```

### `DateTimeToTimestampConverter`

[](#datetimetotimestampconverter)

`Plum\PlumDate\DateTimeToTimestampConverter` converts a `DateTime` object into a timestamp.

```
use Plum\PlumDate\DateTimeToTimestampConverter;

$converter = new DateTimeToTimestampConverter();
$converter->convert(new DateTime()); // -> e.g., 1445448480
```

### `StringToDateTimeConverter`

[](#stringtodatetimeconverter)

`Plum\PlumDate\StringToDateTimeConverter` takes a string and returns a `DateTime` object. The constructor takes an optional `DateTimeZone` object that is passed to the `DateTime` constructor.

```
use Plum\PlumDate\StringToDateTimeConverter;

$converter = new StringToDateTimeConverter();
$converter->convert('2015-10-21 19:28:00'); // -> DateTime

$converter = new StringToDateTimeConverter(new DateTimeZone('Europe/Vienna'));
$converter->convert('2015-10-21 19:28:00'); // -> DateTime
```

### `TimestampToDateTimeConverter`

[](#timestamptodatetimeconverter)

`Plum\PlumDate\TimestampToDateTimeConverter` takes a timestamp and returns a `DateTime` object. An instance of `DateTimeZone` can be passed to the constructor, which will be used to instantiate the `DateTime` object.

```
use Plum\PlumDate\TimestampToDateTimeConverter;

$converter = new TimestampToDateTimeConverter();
$converter->convert(1445448480); // -> DateTime

$converter = new TimestampToDateTimeConverter(new DateTimeZone('Europe/Vienna'));
$converter->convert(1445448480); // -> DateTime
```

### `AfterFilter`

[](#afterfilter)

`Plum\PlumDate\AfterFilter` returns `true` for all dates that are after a given date.

```
use Plum\PlumDate\AfterFilter;

$filter = new AfterFilter(new DateTime('2015-10-21 19:28'));
$filter->filter(new DateTime('2015-10-26 21:00')); // -> true
$filter->filter(new DateTime('1955-11-12 18:38')); // -> false

// Same date as in constructor:
$filter->filter(new DateTime('2015-10-21 19:28')); // -> false
```

### `BeforeFilter`

[](#beforefilter)

`Plum\PlumDate\BeforeFilter` returns `true` for all dates that are before a given date.

```
use Plum\PlumDate\BeforeFilter;

$filter = new BeforeFilter(new DateTime('2015-10-21 19:28'));
$filter->filter(new DateTime('1955-11-12 18:38')); // -> true
$filter->filter(new DateTime('2015-10-26 21:00')); // -> false

// Same date as in constructor:
$filter->filter(new DateTime('2015-10-21 19:28')); // -> false
```

### `RangeFilter`

[](#rangefilter)

`Plum\PlumDate\RangeFilter` returns `true` for all dates that lie within a given range of dates.

```
use Plum\PlumDate\AfterFilter;

$filter = new AfterFilter(new DateTime('2000-01-01 00:00:00'), new Date('2009-12-31 23:59:59'));
$filter->filter(new DateTime('2005-07-07 12:00:00')); // -> true
$filter->filter(new DateTime('2015-10-21 19:28:00')); // -> false

// Same date as in start or end date:
$filter->filter(new DateTime('2000-01-01 00:00:00')); // -> true
$filter->filter(new DateTime('2009-12-31 23:59:59')); // -> true
```

Change Log
----------

[](#change-log)

### Version 0.1 (23 October 2015)

[](#version-01-23-october-2015)

- Initial release

License
-------

[](#license)

The MIT license applies to plumphp/plum-date. For the full copyright and license information, please view the LICENSE file distributed with this source code.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity55

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

3861d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a80f9fc61cd3a7d7779e8f120b458ca4d18fdd885d719bb77d3379b96bf714d9?d=identicon)[florianeckerstorfer](/maintainers/florianeckerstorfer)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/plumphp-plum-date/health.svg)

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

###  Alternatives

[drupol/drupal-conventions

Drupal conventions for coding.

2422.7k1](/packages/drupol-drupal-conventions)

PHPackages © 2026

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