php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54102 Conflicts of regular expressions in parse_date.re
Submitted: 2011-02-25 18:15 UTC Modified: 2021-04-07 09:22 UTC
From: tomas dot brastavicius at quantum dot lt Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.6RC1 OS: Ubuntu
Private report: No CVE-ID: None
 [2011-02-25 18:15 UTC] tomas dot brastavicius at quantum dot lt
Description:
------------
Regular expression year4 conflicts with gnunocolon, and pointeddate2 with both timelong12 and timelong24.

Test script:
---------------
<?php
echo date("Y-m-d H:i:s", strtotime("2460")) . "\n";	// year4 was used
echo date("Y-m-d H:i:s", strtotime("2011")) . "\n";	// gnunocolon was used
echo date("Y-m-d H:i:s", strtotime("20.02.99")) . "\n";	// pointeddate2 was used
echo date("Y-m-d H:i:s", strtotime("20.02.11")) . "\n";	// timelong24 was used

Expected result:
----------------
Used single regular expression independently on date/time range

Actual result:
--------------
2460-02-25 15:17:46
2011-02-25 20:11:00
1999-02-20 00:00:00
2011-02-25 20:02:11


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-07 09:22 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2021-04-07 09:22 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The parser tries its utter best to try to untangle what you feed it. In some cases, it has to make these choices which seem odd. In order to avoid this, use DateTimeImmutable::createFromFormat, which gives you full control over how something is parsed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 08:01:31 2024 UTC