php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24683 ISO8601 weeks date seems incorrect for week 52
Submitted: 2003-07-16 12:08 UTC Modified: 2003-07-17 10:34 UTC
From: s dot vanvelthem at ibelgique dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.2 OS: Redhat Linux 9
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: s dot vanvelthem at ibelgique dot com
New email:
PHP Version: OS:

 

 [2003-07-16 12:08 UTC] s dot vanvelthem at ibelgique dot com
Description:
------------
In PHP4.3.2, the function date('W', $timestamp) behaves differently from PHP4.2.3 concerning the ISO8601 dates 

For example (timestamps has been written in simple form for readablility), 

date('W', '2003-12-31') 
reports 1 in PHP4.3.2 (incorrect? Mysql returns the same result)
reports 53 in PHP4.2.3 (should be the correct behaviour?)
 
(ISO8601 weeks starting on Monday, so i think you could sometimes have a 53rd week in the year?).

It's difficult to differenciate same week between years as 

date('Y-W', '2003-12-31') reports '2003-1'


Sorry for my english,

Thanks for your time.

Seb






Reproduce code:
---------------
$timestamp = strtotime("2003-12-31");
echo date('Y-W', $timestamp);

> outputs '2003-1'


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-16 21:16 UTC] sniper@php.net
It actually works correctly now.

From http://www.cl.cam.ac.uk/~mgk25/iso-time.html :

"In commercial and industrial applications (delivery times, production plans, etc.), especially in Europe, it is often required to refer to a week of a year. Week 01 of a year is per definition the first week that has the Thursday in this year, which is equivalent to the week that contains the fourth day of January. In other words, the first week of a new year is the week that has the majority of its days in the new year. Week 01 might also contain days from the previous year and the week before week 01 of a year is the last week (52 or 53) of the previous year even if it contains days from the new year. A week starts with Monday (day 1) and ends with Sunday (day 7). For example, the first week of the year 1997 lasts from 1996-12-30 to 1997-01-05 and can be written in standard notation as.."
 [2003-07-17 10:34 UTC] mgf@php.net
The result from date() is correct -- the date() formats do not include one for the year corresponding to the ISO8601 week number (perhaps this should be a feature request?).

However, strftime() does -- see http://www.php.net/strftime, and look for the %g and %G conversion specifiers.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 01:01:33 2024 UTC