microinginer / yii2-human-formatter
Installs: 1 328
Dependents: 2
Suggesters: 0
Security: 0
Stars: 8
Watchers: 1
Forks: 1
Open Issues: 0
Type:yii2-extensions
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-11-09 02:13:28 UTC
README
This formatter for yii2 which extend basic formatter. Override datetime and add method of formatting phones (only Russia's number)
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', ] ... ] ... ]