|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #15184 Calculate the quarter with date('Q')?
Submitted: 2002-01-23 11:44 UTC Modified: 2021-10-01 16:36 UTC
Avg. Score:3.6 ± 0.9
Reproduced:16 of 18 (88.9%)
Same Version:9 (56.2%)
Same OS:5 (31.2%)
From: j-f at gmx dot net Assigned:
Status: Wont fix Package: Date/time related
PHP Version: 7.2 OS: -
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: j-f at gmx dot net
New email:
PHP Version: OS:


 [2002-01-23 11:44 UTC] j-f at gmx dot net
I added a note how to calculate the quarter:

But I suggest extending date() with the option 'Q' or 'q'.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-11 19:22 UTC]
One more for you, Derick :)
 [2005-08-12 08:46 UTC]
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.
 [2011-02-21 21:18 UTC] 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 
I don't see a clear sustenance in derick's explanation.
 [2013-04-18 16:07 UTC] 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:

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.

 [2018-04-23 12:10 UTC] 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')));
 [2018-10-13 01:39 UTC] love at sickpeople dot se
GNU coreutils added support for %q in 2016. See

The value is 1 - 4.
 [2018-10-13 02:39 UTC]
-Package: Feature/Change Request +Package: *General Issues
 [2018-10-13 02:39 UTC]
If coreutils/date has it then I think it's worth reconsidering - GNU has already decided what a quarter is and PHP would merely be consistent with that, like it already is when it comes to other date handling problems.
 [2018-11-15 15:46 UTC] love at sickpeople dot se
@requinix: could you please change the status from Wont fix to Open again?
 [2018-11-15 17:04 UTC]
-Status: Wont fix +Status: Re-Opened -PHP Version: 4.1.1 +PHP Version: 7.2 -Assigned To: derick +Assigned To:
 [2018-11-16 00:43 UTC]
-Package: *General Issues +Package: Date/time related
 [2021-10-01 14:32 UTC] lbarkley at gmail dot com
@cmb Can you actually do something to help the community instead of just opening/reassigning issues? Are you a recently hired project manager?
 [2021-10-01 16:36 UTC]
-Status: Re-Opened +Status: Wont fix
 [2021-10-01 16:36 UTC]
This is still a "Wont fix" for previously mentioned reasons.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 16 20:01:29 2024 UTC