1. Go to this page and download the library: Download opencafe/datium 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/ */
opencafe / datium example snippets
Datium.php
js
use OpenCafe\Datium;
echo Datium::now()->get();
js
// Create with YMD
Datium::create( 2016, 1, 1, 12, 56, 13 )->get(); //ouput: 2016-01-01 12:56:13
// Create with YMD without time
Datium::create( 2016, 1, 1 )->get(); // output: 2016-01-01 12:56:13
// Create with timestamp
Datium::createTimestamp( 1420057800 )->get() // output => 2015-01-01 00:00:00
js
// If current date is 2016-01-01 00:00:00 then:
// Add 3 years
Datium::now()->add('3 year')->get();
// output => 2019-01-01 00:00:00
// Add 1 week
Datium::create(2016, 1, 1)->add('1 week')->get();
// output => 2016-01-08 00:00:00
// Add one month
Datium::now()->add('1 month')->get()
// output => 2016-02-01 00:00:00
// Add 1 year, 3 month and 2 days
Datium::now()->add('1 year')
->add('3 month')
->add('2 day')
->add('1 hour')
->add('2 minute')
->add('3 second')
->get();
// output => 2017-04-03 01:02:03
js
// If current date is 2016-01-01 00:00:00 then:
// Sub 3 years
Datium::now()->sub('3 year')->get();
// output => 2013-01-01 00:00:00
// Sub 1 week
Datium::create(2016, 1, 8)->sub('1 week')->get();
// output => 2016-01-01 00:00:00
// Sub one month
Datium::now()->sub('1 month')->get()
// output => 2015-12-01 00:00:00
// Sub 1 year, 3 month and 2 days
Datium::now()->sub('1 year')
->sub('3 month')
->sub('2 day')
->get();
// output => 2014-09-29 00:00:00
js
// current generated date difference with next 5000 days
$diff = Datium::diff(
Datium::now()->object(),
Datium::now()->add('5000 day')->object()
);
echo $diff->days;
// output => 5000
echo $diff->year . ' year, ' . $diff->month . ' month, ' . $diff->day . ' day ';
// ouput => 13 year, 8 month, 7 day
js
// If current date was 2016
// Is 2016 a leap year?
Datium::now()->leap()->get();
// output => FALSE
// Is 2017 a leap year?
Datium::now()->add('1 year')->leap()->get();
// output => TRUE
Datium::now()->to('hijri')->leap()->get();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.