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

react - DayJs, plugin for time format

0 votes
34 views
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
https://day.js.org/docs/en/display/format

 

Please log in or register to response this reference.

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...