Req #15184 [Com]: Calculate the quarter with date('Q')?

From: Date: Sat, 13 Oct 2018 01:39:06 +0000
Subject: Req #15184 [Com]: Calculate the quarter with date('Q')?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217541@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=15184&edit=1

 ID:                 15184
 Comment by:         love at sickpeople dot se
 Reported by:        j-f at gmx dot net
 Summary:            Calculate the quarter with date('Q')?
 Status:             Wont fix
 Type:               Feature/Change Request
 Package:            Feature/Change Request
 Operating System:   -
 PHP Version:        4.1.1
 Assigned To:        derick
 Block user comment: N
 Private report:     N

 New Comment:

GNU coreutils added support for %q in 2016. See https://savannah.gnu.org/forum/forum.php?forum_id=8745

The value is 1 - 4.


Previous Comments:
------------------------------------------------------------------------
[2018-07-15 02:39:55] requinix@php.net

Related To: Bug #76622

------------------------------------------------------------------------
[2018-04-23 12:10:18] vickron at yahoo dot com

if cannot implement date('q') 
at least should implemented strtotime('first day of quarter') ...
its annoying using some interpreted code just to wrap around this...
ceil(date('n')/3) just return the quarter number...
need to calc month 1 to 1-january 2-april 3-july and 4-october
using first_month_of_quarter = ceil(date('n')/3) * 3 -2;
date('Y-m-d', mktime (0,0,0,ceil(date('n')/3) * 3 -2,1,date('Y')));

------------------------------------------------------------------------
[2013-04-18 16:07:03] programming at stefan-koch dot name

I really cannot see from where you derive that "most people start Q1 in the first week of the
year or something". Whereever I look after a Google search, the definition of the quarters is:

First quarter: from the beginning of January to the end of March
Second quarter: from the beginning of April to the end of June
Third quarter: from the beginning of July to the end of September
Fourth quarter: from the beginning of October to the end of December

German Wikipedia lists it even clearer, should also be understandable to English speaking people:

http://de.wikipedia.org/wiki/Quartal#Quartale_und_ihre_Monate

e.g. Quarter I from 1. January to 31. March.

I already submitted a patch in another feature request [1], but judging from PHP's behaviour, I
am pretty sure that nobody will ever implement it (I would understand that MY implementation is not
good enough to be copied).
I want to mention that PHP dev's argumentation as I see it in many bug reports really keeps me
from diving into PHP interpreter development.


[1] https://bugs.php.net/bug.php?id=34932

------------------------------------------------------------------------
[2011-02-21 21:18:27] fernandojmartin at gmail dot com

Why not to just follow the way MySQL behaves?

In that way I'm not obligated to calculate part of the date OUTSIDE the DB server!

The YEAR starts on Jan 1st. Period.
The first week of the year has nothing to do with Q1 if the real date is December 
31.
I don't see a clear sustenance in derick's explanation.

------------------------------------------------------------------------
[2005-08-12 08:46:49] derick@php.net

Some people have different opinions on when the quarter starts. Just saying that it starts at
january 1 is in correct, as most people start Q1 in the first week of the year or something.
That's why I don't think we should add this.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=15184


--
Edit this bug report at https://bugs.php.net/bug.php?id=15184&edit=1


Thread (1 message)

  • love at sickpeople dot se
  • Unknown Message
    • love at sickpeople dot se
« previous php.bugs (#217541) next »