acurrieclark/date-string-utilities

Detects English dates within strings

0.2.1 2020-03-06 11:31 UTC

This package is auto-updated.

Last update: 2020-07-06 12:14:24 UTC


README

This package currently consists of one function which helps to detect dates hidden within a string.

<?php

use acurrieclark\DateStringUtilities\DateInStringFinder;

$string = 'The painters said they had completed the job on 4th March 2020';

$date = DateInStringFinder::find($string);

/**
 * [
 *      'day' => 4,
 *      'month' => 3,
 *      'year' => 2020,
 *  ]
 */

Date Formats

Many Date formats are supported, a full list of which can be seen in the test file.

North American Dates

It should be noted that dates in the format 2/3/2020 will be interpreted as a UK date ie. 2nd March 2020, not 3rd February 2020 as might be expected in the USA and Canada.

Credits

This package borrows from Etienne Tremel's PHP-Find-Date-in-String package.

Contribute

Pull requests are most welcome. In particular, feel free to add to the tests with currently passing examples which you want to preserve in future versions.