hamidgh83 / intldatetime
This class converts Gregorian date into Jalali format.
v1.0.1
2018-10-05 14:25 UTC
Requires
- php: ^7
This package is auto-updated.
Last update: 2024-12-09 18:16:11 UTC
README
The package
Overview
This library can convert Gregorian dates into other calendars with supporting formatting output. It currently supports Jalali date but can be expandable for other calendars.
Requirements
This library requires PHP 7.0 and above to be installed.
Installation
The library can be installed via composer:
$ composer require hamidgh83/intldatetime
Usage
Usage of this library is the same as PHP DateTime library.
Example 1:
$date = new \IntlDateTime\DateTime; // You can change timezone $date->setTimezone(new \DateTimeZone('Asia/Tehran')); // Set an adapter to change calendar type $date->setAdapter(\IntlDateTime\Adapters\AdapterTypeInterface::TYPE_JALALI); // Set a Jalali date $date->setDate(1395, 04, 19); // Add one day to calculate further date $interval = new DateInterval('P1D'); $date->add($interval); echo $date->format("Y/m/d W");
Result
1395/04/20 یکشنبه
Example 2:
$date = new \IntlDateTime\DateTime('2017-08-01'); // Set an adapter to change calendar type $date->setAdapter(\IntlDateTime\Adapters\AdapterTypeInterface::TYPE_JALALI); echo $date->format("Y/m/d W");
Result
1396/05/10 سه شنبه