Let's open the recipe page we created just before developing our custom module. On our recipe page which we created using our custom content type, all time fields (cookTime and prepTime) values are displayed in minutes, for example, 60 minutes and 90 minutes. It would be nice if 60 minutes was displayed as 1 hour and 90 minutes was displayed as 1 1⁄2 hours.
One way we can make this happen is to develop a custom module to create a custom field formatter that will display the duration related fields of cookTime and prepTime as hours instead of minutes.
Following are the basic steps involved in creating a new plugin or creating a custom field formatter:
Create the custom formatter class. This class defines its meta information in its annotation block, which holds the ID of the formatter, label, and field type.
Core ones are defined either by core modules that can be found inside the
Drupal\Core\Field\Plugin\Field\FieldFormatter
and namespace plugins...