PHP code example of gtmassey / quarter

1. Go to this page and download the library: Download gtmassey/quarter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gtmassey / quarter example snippets


//Jan 1, YYYY - Mar 31, YYYY
Quarter::first();

//Apr 1, YYYY - Jun 30, YYYY
Quarter::second();

//Jul 1, YYYY - Sep 30, YYYY
Quarter::third();

//Oct 1, YYYY - Dec 31, YYYY
Quarter::fourth();

//Jan 1, 2020 - Mar 31, 2020
Quarter::first()->year(2020);

//Jan 1, 0020 - Mar 31, 0020
Quarter::first()->year(20);

//Jan 1, 1995 - Mar 31, 1995
Quarter::first()->year(1995);

Quarter::first()->asPeriod();

//July 1, YYYY - September 30, YYYY
Quarter::first()->toFiscal();

//July 1, 1995 - September 30, 1995
Quarter::first()->year(1995)->toFiscal();

//July 1, 1995 - September 30, 1995
Quarter::first()->year(1995)->toFiscal()->asPeriod();

//Jan 1, YYYY - Mar 31, YYYY
Quarter::first();

//Jul 1, YYYY - Sep 30, YYY
Quarter::first()->toFiscal();

//Jul 1, YYYY - Sep 30, YYYY
//Q3
Quarter::third();

//Jul 1, YYYY - Sep 30, YYYY
//Q1
Quarter::first()->toFiscal();

//July 1, 2020
Quarter::third()->year(20)->startDate();

$quarter = Quarter::first()->year(2020);
//Jan 1, 2020 - Mar 31, 2020
$next = $quarter->next();
//Apr 1, 2020 - Jun 30, 2020

$quarter = Quarter::first()->year(2020);
//Jan 1, 2020 - Mar 31, 2020
$previous = $quarter->previous();
//Oct 1, 2019 - Dec 31, 2019

$current = Quarter::current();
//return the dates for the current quarter, regardless of calendar or fiscal dates.

'aliases' => Facade::defaultAliases()->merge([
    // 'Example' => App\Facades\Example::class,
    'Quarter' => Gtmassey\Quarter\Quarter::class,
])->toArray(),

Gtmassey\Quarter\Quarter {#6221
  +startDate: Carbon\CarbonImmutable @1672531200 {#6224
    date: 2023-01-01 00:00:00.0 UTC (+00:00),
  },
  +endDate: Carbon\CarbonImmutable @1680307199 {#6220
    date: 2023-03-31 23:59:59.999999 UTC (+00:00),
  },
}

Gtmassey\Period\Period {
  +startDate: Carbon\CarbonImmutable @1672531200 {
    date: 2023-01-01 00:00:00.0 UTC (+00:00),
  },
  +endDate: Carbon\CarbonImmutable @1680307199 {
    date: 2023-03-31 23:59:59.999999 UTC (+00:00),
  },
}