note 94451 deleted from function.mktime by danbrown
| From: | danbrown@php.net | Date: | Fri, 06 Nov 2009 15:00:40 +0000 |
| Subject: | note 94451 deleted from function.mktime by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162455@lists.php.net to get a copy of this message | ||
Note Submitter: dvorkin at flightmedia dot ru
----
> p2409 at hotmail dot com
> 02-Aug-2009 03:49
> ...
I have more elegant way to get start and stop of the quarter
// $_ts - is timestamp, date() for example
function quarter_borders( $_ts) {
$year = ( int)( date( "Y", $_ts));
$m = ( int)date( "m", $_ts);
$m -= 1;
$startm = $m - ( $m % 3);
$qa[ "start"] = mktime( 0, 0, 0, $startm, 1, $year);
$qa[ "end"] = mktime( 0, 0, 0, $startm + 3, 1, $year);
return( $qa); }
$ts = strtotime( date( "Y-m-d"));
$qa = quarter_borders( $ts);
echo( date( "Y-m-d", $ts) . "\n" );
echo( date( "Y-m-d", $qa[ "start"]) . "\n" );
echo( date( "Y-m-d", $qa[ "end"]) . "\n" );
output:
2009-11-06
2009-09-01
2009-12-01