php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46970 date("W") returning wrong week number
Submitted: 2008-12-30 09:56 UTC Modified: 2008-12-30 12:22 UTC
From: supratiksekhar at gmail dot com Assigned:
Status: Not a bug Package: Calendar related
PHP Version: 5.2.8 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: supratiksekhar at gmail dot com
New email:
PHP Version: OS:

 

 [2008-12-30 09:56 UTC] supratiksekhar at gmail dot com
Description:
------------
I am using php-5.2.6 currently, while writing a function to get week number using date("W") I found that the value it is returning is wrong.
I searched for the solution and found that this is a bug [Bug #33957] in PHP which is already being solved. But when I try for the year 2008 it returns the wrong value. I tried with the latest version of PHP but the problem is still there.

Thanks

Supratik

Reproduce code:
---------------
$datestr = "2008-12-29  00:00:00";
$da = new DateTime($datestr);
$t = $da->format("U");
echo "Week number: " . date("W", $t);

Expected result:
----------------
Week number: 53

Actual result:
--------------
Week number: 01

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-30 10:36 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

W displays the ISO week number, which is really 01 right now (of the ISO year 2009).
 [2008-12-30 12:00 UTC] supratiksekhar at gmail dot com
Thanks for your quick response, I downloaded the PHP Windows snapshot "Windows x86 VC9 (thread safe))" and checked with the date "Mon Dec 29, 2008". It returns the week number of year as "1" where I expect this to return as "53" in ISO standard.

Thanks

Supratik
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC