Download the PHP package damenjo/rutin without Composer
On this page you can find all versions of the php package damenjo/rutin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download damenjo/rutin
More information about damenjo/rutin
Files in damenjo/rutin
Package rutin
Short Description Provide great PHP API Extension for DateTime
License MIT
Informations about the package rutin
Rutin Provide Great PHP API Extension For DateTime Services :+1:
Installation List
You can install this package via:
Dependency Manager | Command |
---|---|
Composer |
Guidelines
You may get the current date and time just only using our now()
method. Here's the example below:
By default, our package will recognized this DateTime format as Y-m-d H:i:s
. If you need to define the specific timezone as well, you can set the first argument directly to the now()
method like this:
If you need to specified another DateTime format, you may also set the first argument for format()
method. Here's the way to do that:
Note: All DateTime keyword format was referred to PHP DateTime Format documentations.
We also have method that can help you to add or substract days
, month
, year
, etc as many as you want. The list of utilities that you can use will be described below:
Method Name | Used For |
---|---|
addDay() |
Add one day to your specific DateTime |
subDay() |
Substract one day to your specific DateTime |
addDays(int $numberOfDays) |
Add N days to your specific DateTime |
addDayIf(callable $prediction) |
Add one day to your specific DateTime with certain condition |
subDayIf(callable $prediction) |
Substract one day to your specific DateTime with certain condition |
addDaysIf(callable $prediction, int $numberOfDays) |
Add N days to your specific DateTime with certain condition |
addMonth() |
Add one month to your specific DateTime |
addMonths(int $numberOfMonths) |
Add N months to your specific DateTime |
addMonthIf(callable $prediction) |
Add one month to your specific DateTime with certain condition |
addMonthsIf(callable $prediction, int $numberOfMonths) |
Add N months to your specific DateTime with certain condition |
addYear() |
Add one year to your specific DateTime |
addYears(int $numberOfYears) |
Add N years to your specific DateTime |
addYearIf(callable $prediction) |
Add one year to your specific DateTime with certain condition |
addYearsIf(callable $prediction, int $numberOfYears) |
Add N years to your specific DateTime with certain condition |
addTimestamp(int $numberOfTimestamp = 1) |
Add defined number of timestamp to your specific DateTime |
addTimestampIf(callable $prediction, int $numberOfTimestamp = 1) |
Add defined number of timestamp to your specific DateTime with certain condition |
[!NOTE] We also now have
add(string $dateElement, int $numberOfDateElement = 1)
orskip(string $dateElement, int $numberOfDateElement = 1)
to make your life easier. We'll describe the example below the existing code, so please take your time to see it ^_^
This is a few example how to use all the listed method above:
[!WARNING]
null
or any type unlessnumber
will cause an error, so please take a note thattry
andcatch
blocks are important to handle the error of your code. For some quick step, lets see this code:
Also, if you have scenario like to add your day by some conditions, you can use addDayIf()
.
Certainly, there is a scenario that make you need to use condition within the add()
method. That is now possible to do with our brand new while()
.
Since this method was calling in front of addition or substraction method like addDay()
or addMonths()
, etc
, this awesome while()
method will determine that addition or substraction functionality will be affected to the current DateTime or not.
[!WARNING]
while()
only will affect to addition or substraction datetime method, not another things likeformat()
License: MIT