Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echo Drupal::service('date.formatter')->formatInterval($seconds);
- namespace Drupalmy_module;
- use DrupalCoreDependencyInjectionContainerBuilder;
- use DrupalCoreDependencyInjectionServiceProviderBase;
- /**
- * Modifies the date formatter service.
- */
- class MyModuleServiceProvider extends ServiceProviderBase {
- /**
- * {@inheritdoc}
- */
- public function alter(ContainerBuilder $container) {
- // Overrides date.formatter class for custom interval formatting.
- $definition = $container->getDefinition('date.formatter');
- $definition->setClass(DateFormatter::class);
- }
- }
Add Comment
Please, Sign In to add comment