Detects English dates within strings
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, * ] */
Many Date formats are supported, a full list of which can be seen in the test file.
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.
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.