Req #34932 [Com]: Quarter as parameter in the Date function

From: Date: Sat, 13 Oct 2018 01:37:48 +0000
Subject: Req #34932 [Com]: Quarter as parameter in the Date function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217540@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=34932&edit=1 ID: 34932 Comment by: love at sickpeople dot se Reported by: sandved at gmail dot com Summary: Quarter as parameter in the Date function Status: Wont fix Type: Feature/Change Request Package: Date/time related PHP Version: 5.1.0RC3 Block user comment: N Private report: N New Comment: The point of having q/Q is that you can pass a format to some method that will compare dates based on the given format. It's useful if you want to do foo('Y-m-00'), foo('Y-q'), foo('Y-W') etc. You don't have to do something like $date = $datetime->format(str_replace('q', ceil($datetime->format('m') / 3), $format)); As for "easily be done in userland". Your code is actually wrong. Previous Comments: ------------------------------------------------------------------------ [2017-01-11 06:51:07] heiglandreas@php.net This can easily be done in userland. Having that in the library only adds to the complexity and is therefore discouraged. You can get the value you want for example using $date = new DateTime('2017-04-01'); echo floor($date->format('m') / 4) + 1 ------------------------------------------------------------------------ [2005-10-20 16:32:15] sandved at gmail dot com Description: ------------ (I tried to add an argument to http://bugs.php.net/bug.php?id=15184 but didn't succeeded): The Date function may need a way to display a quarter defined standard (in SQL for example) as follow Value Description 1 - Period January/March 2 - Period April/June 3 - Period July/Sep 4 - Period Oct/December by using Q as an parameter as in SQL - http://www.techonthenet.com/oracle/functions/to_date.php Reproduce code: --------------- new feature Expected result: ---------------- date('Y\-\QQ') returns 2005-Q1 for all dates 2005-01-01/2005-03-31 2005-Q2 for all dates 2005-04-01/2005-06-30 2005-Q3 for all dates 2005-07-01/2005-09-30 2005-Q4 for all dates 2005-10-01/2005-12-31 Ex: 2005-Q1 for the date 2005-02-09 2005-Q4 for the date 2005-12-14 Actual result: -------------- new feature ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=34932&edit=1

« previous php.bugs (#217540) next »