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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
7 + 45 = ?
Subscribe to this entry?

 
 [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: Tue Jun 18 11:01:31 2024 UTC