How to use the formatDistance function from date-fns
Find comprehensive JavaScript date-fns.formatDistance code examples handpicked from public code repositorys.
GitHub: brkcnbz/statping
40 41 42 43 44 45 46 47 48 49
}, isBefore(date, compare) { return isBefore(date, parseISO(compare)) }, dur(t1, t2) { return formatDistance(t1, t2) }, format(val, type = "EEEE, MMM do h:mma") { return format(val, type) },
0
0
0
+ 47 other calls in file
GitHub: egtofficial/egt-backend
131 132 133 134 135 136 137 138 139 140
discordNick: discordMember ? discordMember.nickname : null, isActive, isPassive, memberSinceInMonths: differenceInMonths(referenceDate, joinDate), memberSinceInYears: differenceInYears(referenceDate, joinDate), relativeMemberTime: formatDistance(joinDate, referenceDate, { locale: de }), membershipNoEqualsAge: parseInt(member.membershipNumber) === birthdayAge, membershipNoEqualsBirthDate: referenceDate.getDate() === birthdayAge, membershipNoEqualsBirthMonth: referenceDate.getMonth() + 1 === birthdayAge, discordRoles: {
0
0
1
GitHub: jwhutchison/time-js
154 155 156 157 158 159
// Relative dates const fnsDate30Days = add(fnsDate, { days: 30 }); console.log('+30 days', format(fnsDate30Days, 'LLL d, yyyy')); console.log('relative', formatRelative(fnsDate30Days, fnsDate30Days)); console.log('duration', formatDistance(fnsDate30Days, fnsDate));
0
0
2
date-fns.format is the most popular function in date-fns (3838 examples)