|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34302 Date('W') do not return leading zeros for week 1 to 9 (as specified in ISO)
Submitted: 2005-08-30 11:05 UTC Modified: 2005-08-30 11:18 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: sandved at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5CVS-2005-08-30 OS: *
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:
Solve the problem:
48 - 40 = ?
Subscribe to this entry?

 [2005-08-30 11:05 UTC] sandved at gmail dot com
The Date function have an ISO compilant Week parameter 'W'

This parameter should return leading zeros for week 1 to 9 (always returning 2 digits). 

Why :
> W   ISO-8601 week number of year, weeks starting on Monday 
> (added in PHP 4.1.0)

This week parameter do not return leading zeros when used like Date('W'), Date('o\WW') etc. for the weeks 1 to 9

According to ISO 8601 weeks should be represented with leading zeros (from section 4.8 Leading zeros
Each date and time component in a defined representation has a defined length, and leading zeros shall be used as
required.) like:

Date       - Week (extended format)
---------- - ----------
1997-12-29 - 1998-W01-1
1998-01-04 - 1998-W01-7
1998-01-01 - 1998-W01-4
1998-12-31 - 1998-W53-4
1992-01-01 - 1992-W01-3 
1992-02-29 - 1992-W09-6
1992-12-31 - 1992-W53-4
1975-01-01 - 1975-W01-3 
1975-12-28 - 1975-W52-7 
1975-12-29 - 1976-W01-1 

Here's a copy of the latest free online copy, only minor changes in the text in the latest version from ISO - also see

Reproduce code:
ECHO date('W',strtotime('4 January 1999'));

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-30 11:18 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Jan 20 20:01:24 2021 UTC