Skip to main content
Module

std/datetime/mod.ts

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

Utilities for dealing with Date objects.

import {
  dayOfYear,
  format,
  isLeap,
} from "https://deno.land/std@0.221.0/datetime/mod.ts";

const date = new Date("2020-07-10T03:24:00");

dayOfYear(date); // 192

format(date, "dd-MM-yyyy"); // "10-07-2020"

isLeap(date); // true

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 in the local time zone.

Returns the number of the day in the year in UTC time.

Calculates 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.

Formats a date to a string with the specified format.

Returns whether the given year is a leap year. Passing in a Date object will return the leap year status of the year of that object and take the current timezone into account. Passing in a number will return the leap year status of that number.

Returns whether the given year is a leap year in UTC time. This always returns the same value regardless of the local timezone.

Parses a date string using the specified format string.

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