Are you first timer at Why not join us and start exchange your programming knowledge with everyone. Register today!

react - DayJs, plugin for time format

0 votes
added Mar 10 in React by lcjr First Warrant Officer (8,030 points)
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';

const created = "<timestamp goes here>";

// Use
{dayjs(created * 1000).fromNow()} 2 days ago
{dayjs(created * 1000).format('DD MMM YYYY')} 01 Feb 2022

// Dayjs Docs


Please log in or register to response this reference. - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.