Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/datetime/mod.ts>difference

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function difference
import { difference } from "https://deno.land/std@0.131.0/datetime/mod.ts";

Calculate difference between two dates.

Parameters

from: Date

Year to calculate difference

to: Date

Year to calculate difference with

optional
options: DifferenceOptions

Options for determining how to respond

example :

import * as datetime from "./mod.ts";

datetime.difference(new Date("2020/1/1"),new Date("2020/2/2"),{ units : ["days","months"] })