PHP code example of mathsgod / date

1. Go to this page and download the library: Download mathsgod/date 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/ */

    

mathsgod / date example snippets


$date = Date::Create(2000, 1, 1);
echo $date->year; //2000
echo $date->month; //1
echo $date->day; //1

$date = Date::Now(); //now
$date->addYears(1); //next year
$date->addDays(1);
$date->addMonths(1);

$tomorrow = Date::CreateFromString("tomorrow"); //tomorrow

$range = DateRange::Create("2020-01-01", "2020-12-31");
echo $range->contains("2020-03-01"); //true
echo $range->contains("2019-03-01"); //false