Git Product home page Git Product logo

jalalidatetimebundle's Introduction

JalaliDateTimeBundle

Brings Jalali (Persian/Iranian) DateTime to Symfony/Twig

Build Status Latest Stable Version

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 #}
...

Checkout availabe formats

2. Form

soon

3. Service

Jalali DateTime service is automatically ready to use due to the symfony service management and dependency injection mechanism.

Format Table

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.