Module

std/datetime/mod.ts

Deno standard library
Go to Latest
import * as mod from "https://dotland.deno.dev/std@0.181.0/datetime/mod.ts";

Utilities for dealing with {@link Date} objects.

The following symbols from unicode LDML are supported:

  • yyyy - numeric year.

  • yy - 2-digit year.

  • M - numeric month.

  • MM - 2-digit month.

  • d - numeric day.

  • dd - 2-digit day.

  • H - numeric hour (0-23 hours).

  • HH - 2-digit hour (00-23 hours).

  • h - numeric hour (1-12 hours).

  • hh - 2-digit hour (01-12 hours).

  • m - numeric minute.

  • mm - 2-digit minute.

  • s - numeric second.

  • ss - 2-digit second.

  • S - 1-digit fractionalSecond.

  • SS - 2-digit fractionalSecond.

  • SSS - 3-digit fractionalSecond.

  • a - dayPeriod, either AM or PM.

  • 'foo' - quoted literal.

  • ./- - unquoted literal.

This module is browser compatible.

Variables

The number of milliseconds in a day.

The number of milliseconds in an hour.

The number of milliseconds in a minute.

The number of milliseconds in a second.

The number of milliseconds in a week.

Functions

Returns the number of the day in the year.

Returns the difference of the 2 given dates in the given units. If the units are omitted, it returns the difference in the all available units.

Takes an input date and a formatString to format to a string.

Returns whether the given date or year (in number) is a leap year or not. based on: https://docs.microsoft.com/en-us/office/troubleshoot/excel/determine-a-leap-year

Takes an input string and a formatString to parse to a date.

Formats the given date to IMF date time format. (Reference: https://tools.ietf.org/html/rfc7231#section-7.1.1.1). IMF is the time format to use when generating times in HTTP headers. The time being formatted must be in UTC for Format to generate the correct format.

Returns the ISO week number of the provided date (1-53).