Skip to content

microinginer/yii2-human-formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yii2-human-formatter

This formatter for yii2 which extend basic formatter. Override datetime and add method of formatting phones (only Russia's number)

russian readme

Example

echo Yii::$app->formatter->asDatetime(time()); // 0 seconds ago
echo Yii::$app->formatter->asDatetime(strtotime('- 1 day')); // Yesterday at 11:55 pm
echo Yii::$app->formatter->asDatetime('2014-08-23 23:55:12'); //  August 23 at 11:55 pm

echo Yii::$app->formatter->asPhone('89254552773'); //  +7 (925) 455-27-73
echo Yii::$app->formatter->asPhone('9254552773'); //  +7 (925) 455-27-73
echo Yii::$app->formatter->asPhone('925 455 27 73'); //  +7 (925) 455-27-73
echo Yii::$app->formatter->asPhone('(925) 455 27-73'); //  +7 (925) 455-27-73
echo GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        'id',
        'title',
        'mobile:phone',
        'created_at:datetime',
        'description:ntext',
    ],
]);

Install

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist microinginer/yii2-human-formatter "dev-master"

or add

"microinginer/yii2-human-formatter": "dev-master"

to the require section of your composer.json file.

add to config:

$config = [
    ...
    'components' => [
        ...
        'formatter'  => [
            'class' => 'microinginer\humanFormatter\HumanFormatter',
        ]
        ...
    ]
    ...
]

About

Форматтер для работы с датой и временем

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages