1. Go to this page and download the library: Download ashishtilara/moment library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ashishtilara / moment example snippets
$m = new \Moment\Moment(); // default is "now" UTC
echo $m->format(); // e.g. 2012-10-03T10:00:00+0000
$m = new Moment('now', 'Europe/Berlin');
echo $m->format(); // e.g. 2012-10-03T12:00:00+0200
$m = new \Moment\Moment('2012-04-25T03:00:00', 'CET');
echo $m->format('l, dS F Y / H:i (e)'); // Wednesday, 25th April 2012 / 03:00 (Europe/Berlin)
$m = new \Moment\Moment('2012-04-25T03:00:00', 'CET');
echo $m->setTimezone('UTC')->format(); // 2012-04-25T01:00:00+0000
$m = new \Moment\Moment('2013-02-01T07:00:00');
$difference = $m->fromNow();
// or from a specific moment
$m = new \Moment\Moment('2013-02-01T07:00:00');
$difference = $m->from('2011-09-25T10:00:00');
// result comes as an array
var_dump($difference);
/* array(5) {
["seconds"]=> string(9) "-19630800"
["minutes"]=> string(7) "-327180"
["hours"]=> string(5) "-5453"
["days"]=> string(7) "-227.21"
["weeks"]=> string(6) "-32.46"
} */
$m = new \Moment\Moment();
// Get the period for the given date
$m->getPeriodByDate('2012-04-08', 'month');
// result as array
[reference] => 2012-04-08, [start] => 2012-04-01, [end] => 2012-04-30, [interval] => 04
$m = new Moment();
// Get the period for the 2nd quarter of 2012
$m->getPeriodByInterval('2012', 'quarter', 2);
// result as array
[reference] => 2012-04-01, [start] => 2012-04-01, [end] => 2012-06-30, [interval] => 2
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.