php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77232 Wrong week of month for 2018-12-31
Submitted: 2018-12-03 11:44 UTC Modified: 2018-12-03 14:21 UTC
From: uli dot staerk at dc1 dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 7.0.32 OS: Linux
Private report: No CVE-ID: None
 [2018-12-03 11:44 UTC] uli dot staerk at dc1 dot com
Description:
------------
The output for date("Y/W") is not correct for 2018-12-31!

Test script:
---------------
php > echo date("Y/W", strtotime('2018-12-30'));
2018/52
php > echo date("Y/W", strtotime('2018-12-31'));
2018/01
php > echo date("Y/W", strtotime('2019-01-01'));
2019/01



Expected result:
----------------
php > echo date("Y/W", strtotime('2018-12-31'));
2019/01

Actual result:
--------------
php > echo date("Y/W", strtotime('2018-12-31'));
2018/01

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-03 11:48 UTC] uli dot staerk at dc1 dot com
-Status: Open +Status: Closed
 [2018-12-03 11:48 UTC] uli dot staerk at dc1 dot com
Meh! Think -> Report
 [2018-12-03 14:02 UTC] cmb@php.net
-Status: Closed +Status: Not a bug
 [2018-12-03 14:21 UTC] danack@php.net
You probably want o/W

From: http://php.net/manual/en/function.date.php

Y	A full numeric representation of a year, 4 digits
o	ISO-8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0)
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 10 17:05:45 2022 UTC