InterviewSolution
| 1. |
What Are Formatted In Yii2? |
|
Answer» FORMATTER is Yii application COMPONENT that is used format view data in readable format for users. By default the formatter is implemented by Yiii18nFormatter which provides a set of methods to format data as date/time, numbers, currencies, and other commonly used formats. You can use the formatter LIKE the following, $formatter = Yii::$app->formatter; // output: January 1, 2014 echo $formatter->asDate('2014-01-01', 'long'); // output: 12.50% echo $formatter->asPercent(0.125, 2); // output: cebe@example.com echo $formatter->asEmail('cebe@example.com'); // output: Yes echo $formatter->asBoolean(true); // it also handles display of null VALUES: // output: (not set) echo $formatter->asDate(null); Formatter is Yii application component that is used format view data in readable format for users. By default the formatter is implemented by Yiii18nFormatter which provides a set of methods to format data as date/time, numbers, currencies, and other commonly used formats. You can use the formatter like the following, $formatter = Yii::$app->formatter; // output: January 1, 2014 echo $formatter->asDate('2014-01-01', 'long'); // output: 12.50% echo $formatter->asPercent(0.125, 2); // output: cebe@example.com echo $formatter->asEmail('cebe@example.com'); // output: Yes echo $formatter->asBoolean(true); // it also handles display of null values: // output: (not set) echo $formatter->asDate(null); |
|