Home Brand style Communications Product
  • Overview
  • Accessibility
    Function arrow
  • Customising Tangram
    Function arrow
  • Deprecations
  • Search engine optimisation
  • Patterns & components
    • Accordion
    • Badge
    • Box
    • Breadcrumbs
    • Breakpoints
    • Button
      Function arrow
    • Card
      Function arrow
    • Carousel
    • Color
      Function arrow
    • Comment
    • Dropdown
    • Flag
    • Forms
      Function arrow
    • Icons
      Function arrow
    • Images
      Function arrow
    • Info box
    • Layout
      Function arrow
    • Link
      Function arrow
    • Lists
    • Loading states & indicators
    • Member representation
    • Modal
      Function arrow
    • Navigation
    • Pagination
    • Pointer
    • Reveal
    • Scrollable container
    • Search and refine
    • Step indicator
    • Tables
    • Tabs
      Function arrow
    • Tag
    • Typography
      Function arrow
    • Z-index
  • Formatters & pipes
    • Currency
    • Date & time
  • Services
    • Focus service
    • Delay service
    • Keyboard service
    • Time service
    • Notifications
  • Directives
    • Auto close
    • Auto focus
    • Drag & Drop
    • Layers
    • Spacing
    • CSS helpers
      Function arrow
    • Ensure
      Function arrow
Current version 22.0.0

Time service

import { TimeService } from '@trademe/tangram';

TimeService provides a mockable source of the current date and time.

Using Angular's dependency injection to access the current time makes it easy to fix "now" in unit tests. For date and time calculations, use date-fns instead.

Example

Properties

now: Date

Returns the current date and time. This can be mocked in unit tests via Angular's dependency injection to fix "now" to a known value.

Proudly made by Trade Me © 2026 Trade Me Limited