Bundle for working with jalali date
Using Composer, just require the ce/jalali-date-bundle
package:
{
"require": {
"ce/jalali-date-bundle": "@dev-master"
}
}
Otherwise, install the library and setup the autoloader yourself.
This library is under development. At this time, there is tow developed services.
For working with Jalali date. You can use this services by getting the service and then calling provided methods.
<?php
// In your action of controller
$jalaliDatetime = $this->get('ce.jalali_date.date_time');
$jalaliDatetime->currentDate(); // return (1392, 2, 7) for example
$jalaliDatetime->getDayOfYear(1392, 11, 4); // Getting the number of passed days
$jalaliDatetime->getWeekNumber(1392, 11, 4); // Getting the number of passed weeks
$jalaliDatetime->getWeekDayOfFirstDayOfYear(1392); // 0 for Saturday and 6 for Friday
For converting Jalali to gregorian date and vice versa. You can use this services by getting the service and then calling provided methods.
<?php
// In your action of controller
$jalaliDatetime = $this->get('ce.jalali_date.date_converter');
$jalaliDatetime->gregorianToJalali(2013, 1, 27); // Convert gregorian date to jalali
$jalaliDatetime->jalaliToGregorian(1392, 11, 4); // Convert jalali date to gregorian
$jalaliDatetime->jalaliToJd(1392, 11, 4); // Convert jalali date to julian
$jalaliDatetime->jalaliToTimestamp(1392, 11, 4); // Getting timestamp of jalali date
This bundle is fully tested.
JalaliDateBundle is released under the MIT License. See the bundled LICENSE file for details.