Download the PHP package phx2600/firstfriday without Composer
On this page you can find all versions of the php package phx2600/firstfriday. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phx2600/firstfriday
More information about phx2600/firstfriday
Files in phx2600/firstfriday
Package firstfriday
Short Description Calculates the next, first Friday of the month.
License MIT
Informations about the package firstfriday
FirstFriday.php
Introduction
Convinience library for calculating the first Friday of a month.
Like this project? Keep me caffeinated by making a donation.
Requirements
- PHP >= 5.6
Install with Composer
Usage
First, import FirstFriday:
Then instantiate the class:
Where $timezone
is a String representation of a timezone to be used for date
calculations. For example America/Phoenix
, Antarctica/Troll
or UTC
. See
http://bit.ly/php-tzs for a full list of available timezones.
Once your class is instantiated you can get the next first Friday of the month
via the next()
method:
or the previous first Friday via the previous()
method:
Both the next()
and the previous()
methods return an instance of
Carbon. This makes date calculations and returning
specific date information easy. For example:
Return a pre-formatted date string:
Return a custom formatted string:
Get the time until the next first Friday in human a human readable format:
Cabon also provides a number of convinient comparison functions, for example:
See the Carbon documentation for more details.
You may also override the value used as "today" in the date calculations. This will allow you to make calculations as if today were another day. This can be accomplished by passing an instance of Carbon as the second parameter when instantiating the FirstFriday class:
or fluently:
NOTE: Be sure to set the timezone of the $today
parameter to the same
timezone passed to the $timezone
argument of the FirstFriday class to ensure
consistency in date calculations. Failing to do so may cause unexpected results.
Troubleshooting
Please report bugs to the GitHub Issue Tracker.
Copyright
This project is liscensed under the MIT License.