This formatter for yii2 which extend basic formatter. Override
datetime and add method of formatting phones (only Russia's number), (*1)
russian readme, (*2)
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., (*3)
Either run, (*4)
php composer.phar require --prefer-dist microinginer/yii2-human-formatter "dev-master"
or add, (*5)
"microinginer/yii2-human-formatter": "dev-master"
to the require section of your composer.json file., (*6)
add to config:, (*7)
$config = [
...
'components' => [
...
'formatter' => [
'class' => 'microinginer\humanFormatter\HumanFormatter',
]
...
]
...
]