import { formatDistanceToNow } from "https://deno.land/x/date_fns@v2.0.0-beta.3/index.js";
Examples
// If today is 1 January 2015, what is the distance to 2 July 2014?
var result = formatDistanceToNow(
new Date(2014, 6, 2)
)
//=> '6 months'
// If today is 1 January 2015, what is the distance to 2 July 2014? var result = formatDistanceToNow( new Date(2014, 6, 2) ) //=> '6 months'
// If now is 1 January 2015 00:00:00,
// what is the distance to 1 January 2015 00:00:15, including seconds?
var result = formatDistanceToNow(
new Date(2015, 0, 1, 0, 0, 15),
{includeSeconds: true}
)
//=> 'less than 20 seconds'
// If now is 1 January 2015 00:00:00, // what is the distance to 1 January 2015 00:00:15, including seconds? var result = formatDistanceToNow( new Date(2015, 0, 1, 0, 0, 15), {includeSeconds: true} ) //=> 'less than 20 seconds'