Download the PHP package lawondyss/moment-php without Composer
On this page you can find all versions of the php package lawondyss/moment-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lawondyss/moment-php
More information about lawondyss/moment-php
Files in lawondyss/moment-php
Package moment-php
Short Description MomentPHP is library for parsing, manipulating and formatting dates.
License GPL-3.0
Homepage https://github.com/Lawondyss/MomentPHP
Informations about the package moment-php
MomentPHP
MomentPHP is library for parsing, manipulating and formatting dates. It's inspired by the JavaScript library Moment.js.
License
Is freely distributable under the terms of the GPL-3 license.
Install
MomentPHP is available on Packagist, where you can get it via Composer.
File composer.json:
Run in command-line:
Parse
Now
Get the current date and time:
String
Create from a string with date time. The string are acceptable same as for function strtotime
(http://www.php.net/manual/en/function.strtotime.php).
Integer
Create from a integer with timestamp. The integer is a number seconds from the Unix Epoch.
DateTime
Create from a instance of the class DateTime (http://www.php.net/manual/en/class.datetime.php):
String + Format
If the string is unrecognized or confusing, you can add its format. The format are same as for method DateTime::createFromFormat
(http://www.php.net/manual/en/datetime.createfromformat.php).
The format may be a field with more formats. Then use the first acceptable format.
Set Timezone
The Timezone is set via the third parameter to the constructor. Timezone may be string from a table with supported Timezones, or instance of the class DateTimeZone (http://www.php.net/manual/en/class.datetimezone.php).
Display
For examples we have:
Format()
Return formating date time. Parameter is same as for function date
(http://www.php.net/manual/en/function.date.php).
Timestamp()
Return number seconds from the Unix Epoch.
Partials from date time
diff()
Get the difference in seconds.
To get the difference in another unit of measurement, pass that measurement as the second argument. Acceptable units: sec, second, seconds, min, minute, minutes, hour, hours, day, days, month, months, year, years
By default return number rounded down. If you want the floating point number, pass TRUE
as the third argument.
from()
A common way of displaying time. This is sometimes called timeago or relative time.
If you can get the value without the suffix, then set second argument as TRUE
.
fromNow()
It's equal as from()
, but starting time is now.
Manipulate
add()
Adds an amount of days, months, years, hours, minutes and seconds. Units is same as for method diff()
.
Adds instance of class DateInterval.
Adds array with parameters for loop add(). [unit => number]
sub()
It's equal as add(), bud for subtracts.
startOf()
Mutates the original moment by setting it to the start of a unit of time. Units is same as for add()
.
endOf()
Mutates the original moment by setting it to the end of a unit of time. Units is same as for add()
.
Query
isLeapYear()
Returns TRUE
if that year is a leap year, and FALSE
if it is not.
isDST()
Checks if the current moment is in daylight savings time.
isBefore()
Check if a moment is before another moment.
If set unit, then beginning both dates set on the unit.
isAfter()
Check if a moment is after another moment. It is the exact opposite method IsBefore().
isSame()
Check if a moment is the same as another moment.
isMomentPHP()
Check if a variable is a MomentPHP object.