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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC