acurrieclark / date-string-utilities
检测字符串中的英文日期
0.3.0
2021-09-27 16:39 UTC
Requires
- php: ^7.2 | ^8.0
Requires (Dev)
- larapack/dd: ^1.1
- mockery/mockery: ^1.3
- phpunit/phpunit: ^8.0
- roave/security-advisories: dev-master
This package is auto-updated.
Last update: 2024-08-27 22:46:35 UTC
README
此包目前包含一个函数,该函数有助于检测字符串中隐藏的日期。
<?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, * ] */
日期格式
支持多种日期格式,完整列表可以在测试文件中查看。
北美日期
需要注意的是,格式为 2/3/2020
的日期将被解释为英国日期,即 2月3日2020年,而不是在美国和加拿大可能预期的 3月2日。
致谢
此包借鉴了Etienne Tremel的PHP-Find-Date-in-String包。
贡献
欢迎提交拉取请求。特别是,您可以自由地添加当前正在通过的示例,这些示例希望在未来的版本中保留。