eexbee / jalali-date-time-bundle
Brings Jalali(Persian/Iranian) DateTime to Symfony/Twig
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-flex
Requires
- php: ^7.1.3
- symfony/config: ^3.4 || ^4.4 || ^5.0
- symfony/dependency-injection: ^3.4 || ^4.4 || ^5.0
- symfony/http-kernel: ^3.4 || ^4.4 || ^5.0
Requires (Dev)
- symfony/framework-bundle: ^3.4 || ^4.4 || ^5.0
- symfony/phpunit-bridge: ^3.4 || ^4.4 || ^5.0
This package is auto-updated.
Last update: 2024-04-22 02:32:32 UTC
README
Brings Jalali (Persian/Iranian) DateTime to Symfony/Twig
Requirements
- symfony > 3.4
Installation
composer require eexbee/jalali-date-time-bundle
Usage
This bundle provides Jalali DateTime tools to be used inside your Controllers, Twig templates and forms.
1. Twig
Use j_datetime_format
twig filter to convert php DateTime object into Jalali format
{# templates/frontend/home.html.twig #} ... {{ datetimeObject|j_datetime_format }} {# ا۲۲:۰، ۰۹ مهر ۱۳۹۹ #} ...
You can Also pass several parameters to the filter to customize the output. Filter definition looks like this:
... j_datetime_format( \DateTime $dateTime, //php DateTime Object $format = 'H:i ,d F Y', //Arbitrary format (checkout format table) $timeZone = 'Asia/Tehran', //Timezone $lang = 'fa' //Output number characters (fa or en) ) ...
Example:
{# templates/frontend/home.html.twig #} ... {{ datetimeObject|j_datetime_format('Y-m-d H:i:s', "Europe/Paris", "en") }} {# output: 1399-07-09 12:27:49 #} ...
2. Form
soon
3. Service
Jalali DateTime service is automatically ready to use due to the symfony service management and dependency injection mechanism.