php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14422 Wrong week-numbers for year 2002
Submitted: 2001-12-11 05:28 UTC Modified: 2001-12-12 08:50 UTC
From: sz at bluemail dot ch Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.0.6 OS: Win32
Private report: No CVE-ID: None
 [2001-12-11 05:28 UTC] sz at bluemail dot ch
// Example: Week of Jan 01, 2002:

$sec = mktime(0,0,0,1,1,2002);
$week = strftime("%W", $sec);

Result: $week = 00 !!!
Should be: 01 !

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-12 05:12 UTC] hholzgra@php.net
nope, see http://php.net/strftime:

"%W - week number of the current year as a decimal number, starting with the first Monday as the first day of the first week"

the uncomplete week before the first monday is week 0

 [2001-12-12 05:12 UTC] hholzgra@php.net
bogusified
 [2001-12-12 06:12 UTC] sz at bluemail dot ch
yes, I see that (week 1 = first monday of the year). But look at your (printed) calendar of 2002:

week 1 beginns at Monday, 31. Dec. 2001, 
and NOT at Monday, 07. Jan. 2002!!!

so the PHP-Function strftime() gives wrong week numbers for the whole year 2002!

A year has 52 or 53 weeks, starting with week 1, ending with week 52 or 53. A "week 0" don't exists!

example:
http://206.67.28.80/afnontv/scheds/60day/6_e201.htm
Week 1 (MON 31 DEC 2001-SUN 6 JAN 2002)
 [2001-12-12 06:31 UTC] sz at bluemail dot ch
and by the way:

week 1 of the year 2003 will start at
Monday, 30. Dec. 2002 (and not Mon. 06. Jan. 2003)
 [2001-12-12 08:50 UTC] hholzgra@php.net
there are (at least) 3 different 'standards'
for week-counting, that's why strftime
has the %U %V and %W modifiers

you have to check which standard your 
calendar uses and which of the three modifiers
corresponds to it

here in Germany this would usualy be %V and not %W,
and i tink it's the same in your country

(but usualy it is not consistent throughout 
a country, so strftime can't use the locale
settings to find out what to do, you have 
to specify what you want)

 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC