motammem/persian_date_bundle

语言: PHP

git: https://github.com/motammem/persian_date_bundle

Symfony2 PersianDateBundle
Symfony2 PersianDateBundle
README.md (中文)

波斯日期捆绑

Symfony2 PersianDateBundle

安装:

composer require mtm/persian-date-bundle:1.0.4

将以下行添加到AppKernel.php中

new Mtm\PersianDateBundle\MtmPersianDateBundle(),

用法:

表格类型:

此捆绑包附带一个提示用户的mtm_persian_date_type表单类型 对于视图层的波斯日期,并将其转换为业务层的标准PHP DateTime对象。 因此,您可以使用Standard PHP DateTime对象作为表单数据。

以下是如何使用它:

$dateTime = new \DateTime('tomorrow');

$this->createForm('mtm_persian_date_type', $dateTime);

树枝过滤器:

此捆绑包还添加了一个非常方便的twig过滤器persian_date来格式化标准PHP DateTime对象。

<td>
    {{ post.createdAt| persian_date("Y-m-d') }}
</td>

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

Persian Date Bundle

Symfony2 PersianDateBundle

Installation:

composer require mtm/persian-date-bundle:1.0.4

add following line to your AppKernel.php

new Mtm\PersianDateBundle\MtmPersianDateBundle(),

Usage:

Form Type:

This bundle comes with a mtm_persian_date_type form type which prompt user
for persian date at view layer and converts it to Standard PHP DateTime object at business layer.
So you can use Standard PHP DateTime object as form data.

Here is how to use it:

$dateTime = new \DateTime('tomorrow');

$this->createForm('mtm_persian_date_type', $dateTime);

Twig Filter:

This bundle also adds a very handy twig filter persian_date to format Standard PHP DateTime object.

<td>
    {{ post.createdAt| persian_date("Y-m-d') }}
</td>