PHPackages                             ikunyemingor/first-or-last-period-date - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ikunyemingor/first-or-last-period-date

ActivePackage[Utility &amp; Helpers](/categories/utility)

ikunyemingor/first-or-last-period-date
======================================

Get the First or Last Day of a Week, Month, Quarter or Year in PHP

1169PHP

Since Jan 25Pushed 7y agoCompare

[ Source](https://github.com/ikunyemingor/First-or-Last-Period-Date)[ Packagist](https://packagist.org/packages/ikunyemingor/first-or-last-period-date)[ RSS](/packages/ikunyemingor-first-or-last-period-date/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

First or Last Period Date
=========================

[](#first-or-last-period-date)

Get the First or Last Day of a Week, Month, Quarter or Year in PHP is a slight retouched of [@davgothic](https://github.com/davgothic) First/Last Day Period [2013 Work](https://davidhancock.co/2013/11/get-the-firstlast-day-of-a-week-month-quarter-or-year-in-php/).

If you've ever needed to find the first or last day of a given period and you're rocking a PHP version greater than or equal to 5.2, today is your lucky day!
Both functions used returns a DateTime object, so you can output the date in any format available to the PHP date() function.

Demo and Examples
-----------------

[](#demo-and-examples)

Please see [CodePad](https://codeinterview.io/playback/UKRKZMMJIC) for a demo.

Installation
------------

[](#installation)

### Requirements

[](#requirements)

PHP &gt;= 5.2

### With Composer - Basic Usage

[](#with-composer---basic-usage)

```
$ composer require ikunyemingor/first-or-last-period-date
```

OR

```
{
    "require": {
        "ikunyemingor/first-or-last-period-date": ">=0.1.1"
    }
}
```

```
