Skip to main content
Very Popular
Latest
function default
import { default } from "https://deno.land/x/date_fns@v2.22.1/formatDistanceToNowStrict/index.js";

Examples

// If today is 1 January 2015, what is the distance to 2 July 2014? var result = formatDistanceToNowStrict( 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 = formatDistanceToNowStrict( new Date(2015, 0, 1, 0, 0, 15) ) //=> '20 seconds'

// If today is 1 January 2015, // what is the distance to 1 January 2016, with a suffix? var result = formatDistanceToNowStrict( new Date(2016, 0, 1), {addSuffix: true} ) //=> 'in 1 year'

// If today is 28 January 2015, // what is the distance to 1 January 2015, in months, rounded up?? var result = formatDistanceToNowStrict(new Date(2015, 0, 1), { unit: 'month', roundingMethod: 'ceil' }) //=> '1 month'

// If today is 1 January 2015, // what is the distance to 1 August 2016 in Esperanto? var eoLocale = require('date-fns/locale/eo') var result = formatDistanceToNowStrict( new Date(2016, 7, 1), {locale: eoLocale} ) //=> '1 jaro'

Parameters

dirtyDate
  • the given date
dirtyOptions