php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #33229 geting a YearWeek correctly
Submitted: 2005-06-03 11:46 UTC Modified: 2005-08-13 21:03 UTC
From: fab097 at gmail dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.3.10 OS: linux
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: fab097 at gmail dot com
New email:
PHP Version: OS:

 

 [2005-06-03 11:46 UTC] fab097 at gmail dot com
Description:
------------
using date("Y",$date) and date("w",$date) is not clean to get the YEARWEEK of a date.
in most of case it looks to work, for example :
with date of first or march 2005, it gives "2005" and "9"

but on certain cases, it's not possible to get REAL YearWeek of a date.
for example : date of 30th of december 2003 is the FIRST week of year 2004 !

then date("w",$date) gives correct week number : 1
but date("Y",$date) gives year 2003 (which is normal)

a function YEARWEEK is missing.
in mySQL I have such a function :
select YEARWEEK('20031231',1); returns "200401"
there are no way in php to get such result with date.

PS : please as mysql add an optional parameters to this function to support first day of the week. (0=sunday, 1=monday)
thank you.

Reproduce code:
---------------
$d=mktime(0,0,0,12,30,2003);
echo date("d/m/y",$d)."\n";
echo "Year :".date("Y",$d)."  Week :".date("W",$d);
echo "\n expected YEARWEEK() : '200401'";



Expected result:
----------------
 the required result of YEARWEEK future function is 200401

Actual result:
--------------
this function does not exist yet, so.. no result.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-13 21:03 UTC] nlopess@php.net
Added to PHP 5.1 as date('o');
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 18 22:00:03 2025 UTC