php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #78591 Short year to full year conversion range not specified
Submitted: 2019-09-23 18:29 UTC Modified: 2019-09-23 18:34 UTC
From: nerketur at hotmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: Windows
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: nerketur at hotmail dot com
New email:
PHP Version: OS:

 

 [2019-09-23 18:29 UTC] nerketur at hotmail dot com
Description:
------------
As seen on the example code below, conversion to full year from short year is done in the range 1970 -> 2069.  However, this is not specified in the documentation.

The reason this isn't "obvious" is because some languages allow you to specify the range of conversion, and others seem to use a different range.
---
From manual page: https://php.net/function.date
---


Test script:
---------------
<?php
for ($x = 10; $x <= 99; $x++) {
	$dateString = "1/1/$x";
	echo "$dateString: " . DateTime::createFromFormat("m/d/y", $dateString)->format("Y") . "<br>";
}
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-23 18:34 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: PHP Language Specification +Package: Date/time related
 [2019-09-23 18:34 UTC] requinix@php.net
You aren't seeing it on the date() page because that function isn't the one that parses date strings.

https://www.php.net/manual/en/datetime.createfromformat.php
> y
> A two digit representation of a year (which is assumed to be in the range 1970-2069, inclusive)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC