Skip to main content
On this page

@std/datetime

Unstable

This @std package is experimental and its API may change without a major version bump.

Overview Jump to heading

Utilities for dealing with Date objects.

import { dayOfYear, isLeap, difference, HOUR, MINUTE, SECOND } from "@std/datetime";
import { assertEquals } from "@std/assert";

assertEquals(dayOfYear(new Date("2019-03-11T03:24:00")), 70);
assertEquals(isLeap(1970), false);

const date0 = new Date("2018-05-14");
const date1 = new Date("2020-05-13");
assertEquals(difference(date0, date1).years, 1);

assertEquals(HOUR / MINUTE, 60);
assertEquals(MINUTE / SECOND, 60);

Add to your project Jump to heading

deno add jsr:@std/datetime

See all symbols in @std/datetime on

Did you find what you needed?

Privacy policy