1. Go to this page and download the library: Download m-jch/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/ */
m-jch / date example snippets
use Date\Date;
use Date\Jalali;
$date = new Jalali('1395/04/10 23:10:05');
$date = new Jalali('۱۳۹۵/۰۴/۱۰ ۲۳:۱۰:۰۵');
$date->format('Y-m-d H:i:s');
echo new Jalali('1395-04-10');
// You can use make static method instead of new instance
// Below examples has same results
$date = (new Jalali('1395/04/10 23:10:05'))->subDays(4);
$date = Jalali::make('1395/04/10 23:10:05')->subDays(4);
echo Jalali::now();
echo Jalali::yesterday();
echo Jalali::tomorrow();
echo Jalali::create(1394, 05, 04, 12, 45, 23);
echo Jalali::createDate(1394, 05, 04);
echo Jalali::createTime(12, 45, 23);
// Jalali to Gregorian
$date = new Jalali('1373/06/05 23:10:05');
echo $date->toGregorian();
$date = new Jalali('1373/06/05 23:10:05');
echo $date->tog()->format('Y-m'); // An aliases for toGregorian method
// Gregorian to Jalali
$date = new Date('2012-06-05 20:05:01');
echo $date->toJalali();
$date = new Date('2012-06-05 20:05:01');
echo $date->toj(); // An aliases for toJalali method
// echo as farsi numbers
echo Jalali::now()->fa()->subDays(4);
echo (new Jalali)->addDays(5)->fa('Y-m-d l'); // Can use just fa() instead of fa()->format()
// Create from timestamp
$date = new Jalali(1466664181);
$date = new Date(1466664181);
$date = Jalali::createFromTimestamp(1466664181);
// Get timestamp
$date->getTimestamp();
$date->format('U');
// Set timestamp
$date->setTimestamp(1466664181);