|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 12:00:02 2025 UTC |
Added to PHP 5.1 as date('o');