1. Go to this page and download the library: Download lawondyss/moment-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lawondyss / moment-php example snippets
$moment = new MomentPHP\MomentPHP();
$string = '1980-12-07';
$string = '7 December 1980';
$string = '+1 week 2 days 4 hours 2 seconds';
$string = 'next Thursday';
$moment = new MomentPHP\MomentPHP($string);
$integer = 345061302;
$integer = time();
$moment = new MomentPHP\MomentPHP($integer);
$moment = new MomentPHP\MomentPHP(new DateTime());
$momentA = new MomentPHP('1980-12-07');
$momentB = new MomentPHP('1980-12-08');
var_dump( $momentA->from($momentB) ); // string(8) "in a day"
var_dump( $momentB->from($momentA) ); // string(9) "a day ago"
$momentA = new MomentPHP('1980-12-07');
$momentB = new MomentPHP('1980-12-08');
var_dump( $momentA->from($momentB, true) ); // string(5) "a day"
var_dump( $momentB->from($momentA, true) ); // string(5) "a day"
$moment = new MomentPHP;
$moment->add(1, 'day');
var_dump( $moment->fromNow() ); // string(8) "in a day"
var_dump( $moment->isSame('1980-12-07') ); // bool(false) because time for compare date is "00:00:00"
var_dump( $moment->startOf('days')->isSame() ); // bool(true) because time for origin date set on "00:00:00"