Files
it-know-how/typescript/bits/19-iso-strings-and-template-literals.md
T
2026-03-27 12:58:01 +01:00

465 B
Executable File

ISO Strings and Template Literals

Your code builds interval strings using toISOString() and a template literal.

Example

const interval = `${start.toISOString()}/${end.toISOString()}`;

Why this format is good

  • ISO format is unambiguous.
  • Easy for backend APIs to parse.
  • Includes timezone info (Z for UTC).

Example value:

2026-03-23T23:00:00.000Z/2026-03-30T22:00:00.000Z

This describes one weekly period as start/end.