PHP code example of i-avatar777 / yii2-component-formatter

1. Go to this page and download the library: Download i-avatar777/yii2-component-formatter 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/ */

    

i-avatar777 / yii2-component-formatter example snippets


return [
    // ...
    'components' => [
        'formatter'       => [
            'class'          => '\iAvatar777\components\FormatterRus\FormatterRus',
            'dateFormat'     => 'php:d.m.b/Y',
            'datetimeFormat' => 'php:d.m.b/Y H:i',
            // ...
        ],
    ],
];

<?= \yii\grid\GridView::widget([
    // ...
    'columns'      => [
        [
            'header'    => 'Дата',
            'format'    => ['date', 'php:d.m.b (Y)'],
            'attribute' => 'date1',
        ],
        [
            'header'    => 'Дата и время',
            'format'    => ['datetime', 'php:d.m.b (Y) H:i:s'],
            'attribute' => 'date2',
        ],
        // ...
    ],
]) 

echo \Yii::$app->formatter->asDate(time(), 'php:j K b (Y)');
echo '<br>';
echo \Yii::$app->formatter->asDatetime(time(), 'php:j k b (Y) H:i:s');