# [PATCH] lenient datetime

- Thread: https://externals.io/message/50092
- Original archive: https://news-web.php.net/php.internals/50092
- Started by Stas Malyshev on 2010-11-03T17:07:27+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #50092 — Stas Malyshev — 2010-11-03T17:07:27+00:00

URL: https://externals.io/message/50092#50092

Hi!

As I previously noted, in DateTime module there's no way to make 
DateTime format parser to parse the string if the string contains more 
data that the format supplies - i.e. if you need 'Y-m-d' and you have 
string '2010-11-02 12:30' - you can't make DateTime accept it without 
pre-parsing. The attached patch adds format character '+' that 
implements that - i.e., if you use format 'Y-m-d+' then the string 
'2010-11-02 12:30' will be parsed successfully, as well as '2010-11-02' 
and string with anything following the date.
The character would make the format 'lenient' when used in any position 
in the string, doesn't have to be at the end.

Any objections? If not, I'll add some unit tests and commit it.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
