How to use the formatRelative function from date-fns
Find comprehensive JavaScript date-fns.formatRelative code examples handpicked from public code repositorys.
GitHub: jwhutchison/time-js
153 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
1 2 3 4 5 6 7 8 9 10
module.exports = function(eleventyConfig) { eleventyConfig.addPassthroughCopy('src/static'); eleventyConfig.addNunjucksShortcode('timeAgo', function(ts) { return formatRelative(new Date(ts * 1000), new Date()); }); return { dir: {
0
0
1
GitHub: RedHatter/printmanager
132 133 134 135 136 137 138 139 140
function formatDate(date) { return format(date, 'MM/dd/yyyy') } function formatDateTime(date) { return formatRelative(date, new Date()) } const dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/
0
0
2
date-fns.format is the most popular function in date-fns (3838 examples)