PHP code example of microinginer / yii2-human-formatter

1. Go to this page and download the library: Download microinginer/yii2-human-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/ */

    

microinginer / yii2-human-formatter example snippets


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',
    ],
]);

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