Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

formatISO

import { formatISO } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
// Represent 18 September 2019 in ISO 8601 format (local time zone is UTC):
const result = formatISO(new Date(2019, 8, 18, 19, 0, 52))
//=> '2019-09-18T19:00:52Z'
@example
// Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC):
const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })
//=> '20190918T190052'
@example
// Represent 18 September 2019 in ISO 8601 format, date only:
const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })
//=> '2019-09-18'
@example
// Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC):
const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })
//=> '19:00:52Z'
function formatISO<DateType extends Date>(date: DateType | number | string, options?: FormatISOOptions): string;
§
formatISO<DateType extends Date>(date: DateType | number | string, options?: FormatISOOptions): string
[src]

§Type Parameters

§
DateType extends Date
[src]

§Parameters

§
date: DateType | number | string
[src]
  • The original date
§
options?: FormatISOOptions optional
[src]
  • An object with options.

§Return Type

§
string
[src]

The formatted date string (in loca.l time zone)