Guest User

Untitled

a guest
Apr 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. echo Drupal::service('date.formatter')->formatInterval($seconds);
  2.  
  3. namespace Drupalmy_module;
  4.  
  5. use DrupalCoreDependencyInjectionContainerBuilder;
  6. use DrupalCoreDependencyInjectionServiceProviderBase;
  7.  
  8. /**
  9. * Modifies the date formatter service.
  10. */
  11. class MyModuleServiceProvider extends ServiceProviderBase {
  12.  
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function alter(ContainerBuilder $container) {
  17. // Overrides date.formatter class for custom interval formatting.
  18. $definition = $container->getDefinition('date.formatter');
  19. $definition->setClass(DateFormatter::class);
  20. }
  21. }
Add Comment
Please, Sign In to add comment