Download the PHP package madbyad/mpl-date-time without Composer
On this page you can find all versions of the php package madbyad/mpl-date-time. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download madbyad/mpl-date-time
More information about madbyad/mpl-date-time
Files in madbyad/mpl-date-time
Package mpl-date-time
Short Description a library for advance date time formatting and calculation
License MIT
Informations about the package mpl-date-time
MPL DateTime
The MPL (MadByAd PHP Library) DateTime is a library used for advance date and time system. This library include, easily format and get the current date or/and time, a calculator for calculating time such as what the date is 20 days later or what the date is 20 days previously
- MPL DateTime
- Installation
- Include
- Date class
- Get Method
- GetArray Method
- GetUnix Method
- Time Class
- Setting Time
- Adding Time
- Subtracting Time
- Getting Time
- DateCalculator Class
- Adding Time To Date
- Subtracting Time From Date
- Calculate Time Gap
- DateFormat Class
Installation
to install the package go ahead and open composer then write the command
Include
The MPL DateTime library. The library include 4 class. The Date
class is used for advance storing and formatting of date, the Time
class is used for advance storing and formatting of time, The DateFormat
class which store a list of date formats you can use, and the DateCalculator
class is used for calculating date such as what date will it be 20 days later or 20 days previously
Date class
The Date(int $time = null, bool $fromToday = false)
class is used for advance storing and formatting of date. When creating a new Date
class, it takes 2 optional parameter. The first is the time, if not given then it will default to null
which will get the current date, if 0
then it will mean the beggining of the unix timestamp 1 January 1970
, if it 86400
then it will mean 1 day after the beggining of the unix timestamp 2 January 1970
. The second is to determine whether getting the time from the beggining of the unix timestamp or from today, if false
then the time 0
will get the beggining of the unix timestamp, if true
then the time 0
will get the current date, the time 86400
will get tommorow, and the time -86400
will get yesterday
Example
Get Method
The get(string $format)
will return the stored date data into a formatted date string, for the format you can get it from the DateFormat
class which has a bunch of const that can be used for different type of format
Example
output
GetArray Method
The getArray()
method will return the stored date in a form of an associative array
Example
output
GetUnix Method
The getUnix()
method is will return the stored date in a form of a unix timestamp
Time Class
The Time(int $time = 0)
class is used for advance storing and formatting of time. When creating a new class it take 1 optional parameter and that is the time (in a form of unix timestamp) default is 0
Example
Setting Time
To set the time to a certain amount of time you can use the following method below. It only takes 1 parameter and that is the amount
Adding Time
To add a certain amount of time you can use the following method below. It only takes 1 parameter and that is the amount
Subtracting Time
To subtract a certain amount of time you can use the following method below. It only takes 1 parameter and that is the amount
Getting Time
To get a time you can use these method
To get the time as a form of associative array you can use the get()
method
Example
ouput
To get the time as a formatted string you can use the getString()
method
Example
ouput
DateCalculator Class
The DateCalculator
class contain methods for date and time calculation
Adding Time To Date
To add a time to a date use the add(Date $date, Time $time)
method, it takes only 2 parameter. The first is the date and the second is the time
Example
Output
Subtracting Time From Date
To subtract a time from a date use the subtract(Date $date, Time $time)
method, it takes only 2 parameter. The first is the date and the second is the time
Example
Output
Calculate Time Gap
To calculate the time gap between 2 date you can use the timeGap(Date $firstDate, Date $secondDate)
method which only takes 2 parameter and both of those are the date
Example
output
DateFormat Class
The DateFormat
class contains a list of constant which can be used to format a date in different variations
Constant | Description |
---|---|
D_M_YY |
the date format in day (without leading zero), month (without leading zero), year (two digit) |
D_M_YY__HOUR_MIN |
the date format in day (without leading zero), month (without leading zero), year (two digit), hour, minute |
D_M_YY__HOUR_MIN_SEC |
the date format in day (without leading zero), month (without leading zero), year (two digit), hour, minute, second |
D_MM_YY |
the date format in day (without leading zero), month (with leading zero), year (two digit) |
D_MM_YY__HOUR_MIN |
the date format in day (without leading zero), month (with leading zero), year (two digit), hour, minute |
D_MM_YY__HOUR_MIN_SEC |
the date format in day (without leading zero), month (with leading zero), year (two digit), hour, minute, second |
D_MONTH_YY |
the date format in day (without leading zero), month (name), year (two digit) |
D_MONTH_YY__HOUR_MIN |
the date format in day (without leading zero), month (name), year (two digit), hour, minute |
D_MONTH_YY__HOUR_MIN_SEC |
the date format in day (without leading zero), month (name), year (two digit), hour, minute, second |
DD_M_YY |
the date format in day (with leading zero), month (without leading zero), year (two digit) |
DD_M_YY__HOUR_MIN |
the date format in day (with leading zero), month (without leading zero), year (two digit), hour, minute |
DD_M_YY__HOUR_MIN_SEC |
the date format in day (with leading zero), month (without leading zero), year (two digit), hour, minute, second |
DD_MM_YY |
the date format in day (with leading zero), month (with leading zero), year (two digit) |
DD_MM_YY__HOUR_MIN |
the date format in day (with leading zero), month (with leading zero), year (two digit), hour, minute |
DD_MM_YY__HOUR_MIN_SEC |
the date format in day (with leading zero), month (with leading zero), year (two digit), hour, minute, second |
DD_MONTH_YY |
the date format in day (with leading zero), month (name), year (two digit) |
DD_MONTH_YY__HOUR_MIN |
the date format in day (with leading zero), month (name), year (two digit), hour, minute |
DD_MONTH_YY__HOUR_MIN_SEC |
the date format in day (with leading zero), month (name), year (two digit), hour, minute, second |
DAY_M_YY |
the date format in day (name), month (without leading zero), year (two digit) |
DAY_M_YY__HOUR_MIN |
the date format in day (name), month (without leading zero), year (two digit), hour, minute |
DAY_M_YY__HOUR_MIN_SEC |
the date format in day (name), month (without leading zero), year (two digit), hour, minute, second |
DAY_MM_YY |
the date format in day (name), month (with leading zero), year (two digit) |
DAY_MM_YY__HOUR_MIN |
the date format in day (name), month (with leading zero), year (two digit), hour, minute |
DAY_MM_YY__HOUR_MIN_SEC |
the date format in day (name), month (with leading zero), year (two digit), hour, minute, second |
DAY_MONTH_YY |
the date format in day (name), month (name), year (two digit) |
DAY_MONTH_YY__HOUR_MIN |
the date format in day (name), month (name), year (two digit), hour, minute |
DAY_MONTH_YY__HOUR_MIN_SEC |
the date format in day (name), month (name), year (two digit), hour, minute, second |
D_M_YYYY |
the date format in day (without leading zero), month (without leading zero), year (four digit) |
D_M_YYYY__HOUR_MIN |
the date format in day (without leading zero), month (without leading zero), year (four digit), hour, minute |
D_M_YYYY__HOUR_MIN_SEC |
the date format in day (without leading zero), month (without leading zero), year (four digit), hour, minute, second |
D_MM_YYYY |
the date format in day (without leading zero), month (with leading zero), year (four digit) |
D_MM_YYYY__HOUR_MIN |
the date format in day (without leading zero), month (with leading zero), year (four digit), hour, minute |
D_MM_YYYY__HOUR_MIN_SEC |
the date format in day (without leading zero), month (with leading zero), year (four digit), hour, minute, second |
D_MONTH_YYYY |
the date format in day (without leading zero), month (name), year (four digit) |
D_MONTH_YYYY__HOUR_MIN |
the date format in day (without leading zero), month (name), year (four digit), hour, minute |
D_MONTH_YYYY__HOUR_MIN_SEC |
the date format in day (without leading zero), month (name), year (four digit), hour, minute, second |
DD_M_YYYY |
the date format in day (with leading zero), month (without leading zero), year (four digit) |
DD_M_YYYY__HOUR_MIN |
the date format in day (with leading zero), month (without leading zero), year (four digit), hour, minute |
DD_M_YYYY__HOUR_MIN_SEC |
the date format in day (with leading zero), month (without leading zero), year (four digit), hour, minute, second |
DD_MM_YYYY |
the date format in day (with leading zero), month (with leading zero), year (four digit) |
DD_MM_YYYY__HOUR_MIN |
the date format in day (with leading zero), month (with leading zero), year (four digit), hour, minute |
DD_MM_YYYY__HOUR_MIN_SEC |
the date format in day (with leading zero), month (with leading zero), year (four digit), hour, minute, second |
DD_MONTH_YYYY |
the date format in day (with leading zero), month (name), year (four digit) |
DD_MONTH_YYYY__HOUR_MIN |
the date format in day (with leading zero), month (name), year (four digit), hour, minute |
DD_MONTH_YYYY__HOUR_MIN_SEC |
the date format in day (with leading zero), month (name), year (four digit), hour, minute, second |
DAY_M_YYYY |
the date format in day (name), month (without leading zero), year (four digit) |
DAY_M_YYYY__HOUR_MIN |
the date format in day (name), month (without leading zero), year (four digit), hour, minute |
DAY_M_YYYY__HOUR_MIN_SEC |
the date format in day (name), month (without leading zero), year (four digit), hour, minute, second |
DAY_MM_YYYY |
the date format in day (name), month (with leading zero), year (four digit) |
DAY_MM_YYYY__HOUR_MIN |
the date format in day (name), month (with leading zero), year (four digit), hour, minute |
DAY_MM_YYYY__HOUR_MIN_SEC |
the date format in day (name), month (with leading zero), year (four digit), hour, minute, second |
DAY_MONTH_YYYY |
the date format in day (name), month (name), year (four digit) |
DAY_MONTH_YYYY__HOUR_MIN |
the date format in day (name), month (name), year (four digit), hour, minute |
DAY_MONTH_YYYY__HOUR_MIN_SEC |
the date format in day (name), month (name), year (four digit), hour, minute, second |
M_D_YY |
the date format in month (without leading zero), day (without leading zero), year (two digit) |
M_D_YY__HOUR_MIN |
the date format in month (without leading zero), day (without leading zero), year (two digit), hour, minute |
M_D_YY__HOUR_MIN_SEC |
the date format in month (without leading zero), day (without leading zero), year (two digit), hour, minute, second |
MM_D_YY |
the date format in month (with leading zero), day (without leading zero), year (two digit) |
MM_D_YY__HOUR_MIN |
the date format in month (with leading zero), day (without leading zero), year (two digit), hour, minute |
MM_D_YY__HOUR_MIN_SEC |
the date format in month (with leading zero), day (without leading zero), year (two digit), hour, minute, second |
MONTH_D_YY |
the date format in month (name), day (without leading zero), year (two digit) |
MONTH_D_YY__HOUR_MIN |
the date format in month (name), day (without leading zero), year (two digit), hour, minute |
MONTH_D_YY__HOUR_MIN_SEC |
the date format in month (name), day (without leading zero), year (two digit), hour, minute, second |
M_DD_YY |
the date format in month (without leading zero), day (with leading zero), year (two digit) |
M_DD_YY__HOUR_MIN |
the date format in month (without leading zero), day (with leading zero), year (two digit), hour, minute |
M_DD_YY__HOUR_MIN_SEC |
the date format in month (without leading zero), day (with leading zero), year (two digit), hour, minute, second |
MM_DD_YY |
the date format in month (with leading zero), day (with leading zero), year (two digit) |
MM_DD_YY__HOUR_MIN |
the date format in month (with leading zero), day (with leading zero), year (two digit), hour, minute |
MM_DD_YY__HOUR_MIN_SEC |
the date format in month (with leading zero), day (with leading zero), year (two digit), hour, minute, second |
MONTH_DD_YY |
the date format in month (name), day (with leading zero), year (two digit) |
MONTH_DD_YY__HOUR_MIN |
the date format in month (name), day (with leading zero), year (two digit), hour, minute |
MONTH_DD_YY__HOUR_MIN_SEC |
the date format in month (name), day (with leading zero), year (two digit), hour, minute, second |
M_DAY_YY |
the date format in month (without leading zero), day (name), year (two digit) |
M_DAY_YY__HOUR_MIN |
the date format in month (without leading zero), day (name), year (two digit), hour, minute |
M_DAY_YY__HOUR_MIN_SEC |
the date format in month (without leading zero), day (name), year (two digit), hour, minute, second |
MM_DAY_YY |
the date format in month (with leading zero), day (name), year (two digit) |
MM_DAY_YY__HOUR_MIN |
the date format in month (with leading zero), day (name), year (two digit), hour, minute |
MM_DAY_YY__HOUR_MIN_SEC |
the date format in month (with leading zero), day (name), year (two digit), hour, minute, second |
MONTH_DAY_YY |
the date format in month (name), day (name), year (two digit) |
MONTH_DAY_YY__HOUR_MIN |
the date format in month (name), day (name), year (two digit), hour, minute |
MONTH_DAY_YY__HOUR_MIN_SEC |
the date format in month (name), day (name), year (two digit), hour, minute, second |
M_D_YYYY |
the date format in month (without leading zero), day (without leading zero), year (four digit) |
M_D_YYYY__HOUR_MIN |
the date format in month (without leading zero), day (without leading zero), year (four digit), hour, minute |
M_D_YYYY__HOUR_MIN_SEC |
the date format in month (without leading zero), day (without leading zero), year (four digit), hour, minute, second |
MM_D_YYYY |
the date format in month (with leading zero), day (without leading zero), year (four digit) |
MM_D_YYYY__HOUR_MIN |
the date format in month (with leading zero), day (without leading zero), year (four digit), hour, minute |
MM_D_YYYY__HOUR_MIN_SEC |
the date format in month (with leading zero), day (without leading zero), year (four digit), hour, minute, second |
MONTH_D_YYYY |
the date format in month (name), day (without leading zero), year (four digit) |
MONTH_D_YYYY__HOUR_MIN |
the date format in month (name), day (without leading zero), year (four digit), hour, minute |
MONTH_D_YYYY__HOUR_MIN_SEC |
the date format in month (name), day (without leading zero), year (four digit), hour, minute, second |
M_DD_YYYY |
the date format in month (without leading zero), day (with leading zero), year (four digit) |
M_DD_YYYY__HOUR_MIN |
the date format in month (without leading zero), day (with leading zero), year (four digit), hour, minute |
M_DD_YYYY__HOUR_MIN_SEC |
the date format in month (without leading zero), day (with leading zero), year (four digit), hour, minute, second |
MM_DD_YYYY |
the date format in month (with leading zero), day (with leading zero), year (four digit) |
MM_DD_YYYY__HOUR_MIN |
the date format in month (with leading zero), day (with leading zero), year (four digit), hour, minute |
MM_DD_YYYY__HOUR_MIN_SEC |
the date format in month (with leading zero), day (with leading zero), year (four digit), hour, minute, second |
MONTH_DD_YYYY |
the date format in month (name), day (with leading zero), year (four digit) |
MONTH_DD_YYYY__HOUR_MIN |
the date format in month (name), day (with leading zero), year (four digit), hour, minute |
MONTH_DD_YYYY__HOUR_MIN_SEC |
the date format in month (name), day (with leading zero), year (four digit), hour, minute, second |
M_DAY_YYYY |
the date format in month (without leading zero), day (name), year (four digit) |
M_DAY_YYYY__HOUR_MIN |
the date format in month (without leading zero), day (name), year (four digit), hour, minute |
M_DAY_YYYY__HOUR_MIN_SEC |
the date format in month (without leading zero), day (name), year (four digit), hour, minute, second |
MM_DAY_YYYY |
the date format in month (with leading zero), day (name), year (four digit) |
MM_DAY_YYYY__HOUR_MIN |
the date format in month (with leading zero), day (name), year (four digit), hour, minute |
MM_DAY_YYYY__HOUR_MIN_SEC |
the date format in month (with leading zero), day (name), year (four digit), hour, minute, second |
MONTH_DAY_YYYY |
the date format in month (name), day (name), year (four digit) |
MONTH_DAY_YYYY__HOUR_MIN |
the date format in month (name), day (name), year (four digit), hour, minute |
MONTH_DAY_YYYY__HOUR_MIN_SEC |
the date format in month (name), day (name), year (four digit), hour, minute, second |
YY_M_D |
the date format in year (two digit), month (without leading zero), day (without leading zero) |
YY_M_D__HOUR_MIN |
the date format in year (two digit), month (without leading zero), day (without leading zero), hour, minute |
YY_M_D__HOUR_MIN_SEC |
the date format in year (two digit), month (without leading zero), day (without leading zero), hour, minute, second |
YY_MM_D |
the date format in year (two digit), month (with leading zero), day (without leading zero) |
YY_MM_D__HOUR_MIN |
the date format in year (two digit), month (with leading zero), day (without leading zero), hour, minute |
YY_MM_D__HOUR_MIN_SEC |
the date format in year (two digit), month (with leading zero), day (without leading zero), hour, minute, second |
YY_MONTH_D |
the date format in year (two digit), month (name), day (without leading zero) |
YY_MONTH_D__HOUR_MIN |
the date format in year (two digit), month (name), day (without leading zero), hour, minute |
YY_MONTH_D__HOUR_MIN_SEC |
the date format in year (two digit), month (name), day (without leading zero), hour, minute, second |
YY_M_DD |
the date format in year (two digit), month (without leading zero), day (with leading zero) |
YY_M_DD__HOUR_MIN |
the date format in year (two digit), month (without leading zero), day (with leading zero), hour, minute |
YY_M_DD__HOUR_MIN_SEC |
the date format in year (two digit), month (without leading zero), day (with leading zero), hour, minute, second |
YY_MM_DD |
the date format in year (two digit), month (with leading zero), day (with leading zero) |
YY_MM_DD__HOUR_MIN |
the date format in year (two digit), month (with leading zero), day (with leading zero), hour, minute |
YY_MM_DD__HOUR_MIN_SEC |
the date format in year (two digit), month (with leading zero), day (with leading zero), hour, minute, second |
YY_MONTH_DD |
the date format in year (two digit), month (name), day (with leading zero) |
YY_MONTH_DD__HOUR_MIN |
the date format in year (two digit), month (name), day (with leading zero), hour, minute |
YY_MONTH_DD__HOUR_MIN_SEC |
the date format in year (two digit), month (name), day (with leading zero), hour, minute, second |
YY_M_DAY |
the date format in year (two digit), month (without leading zero), day (name) |
YY_M_DAY__HOUR_MIN |
the date format in year (two digit), month (without leading zero), day (name), hour, minute |
YY_M_DAY__HOUR_MIN_SEC |
the date format in year (two digit), month (without leading zero), day (name), hour, minute, second |
YY_MM_DAY |
the date format in year (two digit), month (with leading zero), day (name) |
YY_MM_DAY__HOUR_MIN |
the date format in year (two digit), month (with leading zero), day (name), hour, minute |
YY_MM_DAY__HOUR_MIN_SEC |
the date format in year (two digit), month (with leading zero), day (name), hour, minute, second |
YY_MONTH_DAY |
the date format in year (two digit), month (name), day (name) |
YY_MONTH_DAY__HOUR_MIN |
the date format in year (two digit), month (name), day (name), hour, minute |
YY_MONTH_DAY__HOUR_MIN_SEC |
the date format in year (two digit), month (name), day (name), hour, minute, second |
YYYY_M_D |
the date format in year (four digit), month (without leading zero), day (without leading zero) |
YYYY_M_D__HOUR_MIN |
the date format in year (four digit), month (without leading zero), day (without leading zero), hour, minute |
YYYY_M_D__HOUR_MIN_SEC |
the date format in year (four digit), month (without leading zero), day (without leading zero), hour, minute, second |
YYYY_MM_D |
the date format in year (four digit), month (with leading zero), day (without leading zero) |
YYYY_MM_D__HOUR_MIN |
the date format in year (four digit), month (with leading zero), day (without leading zero), hour, minute |
YYYY_MM_D__HOUR_MIN_SEC |
the date format in year (four digit), month (with leading zero), day (without leading zero), hour, minute, second |
YYYY_MONTH_D |
the date format in year (four digit), month (name), day (without leading zero) |
YYYY_MONTH_D__HOUR_MIN |
the date format in year (four digit), month (name), day (without leading zero), hour, minute |
YYYY_MONTH_D__HOUR_MIN_SEC |
the date format in year (four digit), month (name), day (without leading zero), hour, minute, second |
YYYY_M_DD |
the date format in year (four digit), month (without leading zero), day (with leading zero) |
YYYY_M_DD__HOUR_MIN |
the date format in year (four digit), month (without leading zero), day (with leading zero), hour, minute |
YYYY_M_DD__HOUR_MIN_SEC |
the date format in year (four digit), month (without leading zero), day (with leading zero), hour, minute, second |
YYYY_MM_DD |
the date format in year (four digit), month (with leading zero), day (with leading zero) |
YYYY_MM_DD__HOUR_MIN |
the date format in year (four digit), month (with leading zero), day (with leading zero), hour, minute |
YYYY_MM_DD__HOUR_MIN_SEC |
the date format in year (four digit), month (with leading zero), day (with leading zero), hour, minute, second |
YYYY_MONTH_DD |
the date format in year (four digit), month (name), day (with leading zero) |
YYYY_MONTH_DD__HOUR_MIN |
the date format in year (four digit), month (name), day (with leading zero), hour, minute |
YYYY_MONTH_DD__HOUR_MIN_SEC |
the date format in year (four digit), month (name), day (with leading zero), hour, minute, second |
YYYY_M_DAY |
the date format in year (four digit), month (without leading zero), day (name) |
YYYY_M_DAY__HOUR_MIN |
the date format in year (four digit), month (without leading zero), day (name), hour, minute |
YYYY_M_DAY__HOUR_MIN_SEC |
the date format in year (four digit), month (without leading zero), day (name), hour, minute, second |
YYYY_MM_DAY |
the date format in year (four digit), month (with leading zero), day (name) |
YYYY_MM_DAY__HOUR_MIN |
the date format in year (four digit), month (with leading zero), day (name), hour, minute |
YYYY_MM_DAY__HOUR_MIN_SEC |
the date format in year (four digit), month (with leading zero), day (name), hour, minute, second |
YYYY_MONTH_DAY |
the date format in year (four digit), month (name), day (name) |
YYYY_MONTH_DAY__HOUR_MIN |
the date format in year (four digit), month (name), day (name), hour, minute |
YYYY_MONTH_DAY__HOUR_MIN_SEC |
the date format in year (four digit), month (name), day (name), hour, minute, second |