Skip to content

acurrieclark/date-string-utilities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Date String Utilities

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.

About

A PHP utility to help detect dates hidden in strings

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages