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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tomas dot brastavicius at quantum dot lt
New email:
PHP Version: OS:

 

 [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-2021 The PHP Group
All rights reserved.
Last updated: Wed Apr 21 21:01:24 2021 UTC