PHP code example of pouyasoft_ir / simple-date-bundle

1. Go to this page and download the library: Download pouyasoft_ir/simple-date-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pouyasoft_ir / simple-date-bundle example snippets


$shamsiString = $this->get('pouya_soft.j_sdate_service')->georgianToPersian(new \DateTime(), 'yyyy-MM-dd E');
//result: ۱۳۹۴-۱۱-۲۲ دوشنبه
$shamsiString = $this->get('pouya_soft.j_sdate_service')->persianToGeorgian('1394-11-22 دوشنبه', 'yyyy-MM-dd E');
//result: An instance of DateTime

$builder
    ->add('date', PouyaSoftSDateType::class, [
        'serverFormat' => 'yyyy/MM/dd',
        'pickerOptions' => [
            'Format' => 'yyyy/MM/dd',
            'EnableTimePicker' => true,
            'GroupId' => 'group1',
            'FromDate' => true,
            'DisableBeforeToday' => true,
        ]
    ])
    ->add('date2', PouyaSoftSDateType::class, [
        'serverFormat' => 'yyyy-MM-dd E',
        'pickerOptions' => [
            'Format' => 'yyyy/MM/dd',
            'EnableTimePicker' => true,
            'GroupId' => 'group1',
            'ToDate' => true,
        ]
    ])

$ php composer 
twig
{{ date|gpDate }} <br>
{{ date|gpDate('yyyy-MM-dd E') }} <br>
{{ '1394/11/22'|gpDate }} <br>
{{ '1394-11-22 دوشنبه'|gpDate('yyyy-MM-dd E') }} <br>