/simple-date

simple code to format Date

Primary LanguageTypeScript

simple-date

Simple code to format date, without timezone support.

Prefer Intl.DateTimeFormat, if available.

usage

import { simpleDate, simpleDateUTC, format, padZero } from "./simple-date.ts";

console.log(
    format(
        simpleDate(new Date(2000, 0, 1, 1, 1, 1, 1)),
        // OR: simpleDateUTC(...)
        ({ year, month, date }) => `${year}/${padZero(month, 2)}/${padZero(date, 2)}`
    )
);