Moment duration

Source: https://stackoverflow.com/questions/18623783/get-the-time-difference-between-two-datetimes/34672015

moment.duration(now.diff(then)).humanize()


public getDurationText(date1, date2) {
if (!date1) {
return '';
}
// check null date2 (is current date)
const date2Tmp = date2 ? date2 : new Date();
// return
return moment.duration(moment(date2Tmp).diff(moment(date1))).humanize();
}

Không có nhận xét nào:

StaticImage

  import React , { useEffect , useRef } from "react" import { StaticImage } from "gatsby-plugin-image" impor...