본문 바로가기
TIL

134. [React] timeago.js 라이브러리 사용 TIL 23.02.24

by 새싹_v 2023. 2. 24.
728x90


 

timeago.js

 

사용 전

import {format, register } from 'timeago.js' //register 한국어 선택
import koLocale from 'timeago.js/lib/lang/ko' //한국어 선택

register('ko', koLocale)

function VideoCard(){
	return (
    	<p className='text-sm opacity-80'>{publishedAt}</p>
    )
}

 

결과

 

 

라이브러리 사용해 보기

 

👉 사용방법

yarn add timeago.js

 

import {format, register } from 'timeago.js' //임포트하기 register 한국어 선택
import koLocale from 'timeago.js/lib/lang/ko' //한국어 선택

register('ko', koLocale)

function VideoCard(){
	return (
    	<p className='text-sm opacity-80'>{format(publishedAt, 'ko')}</p>
    )
}

 

결과

 

 

 

https://www.npmjs.com/package/timeago.js/v/4.0.0-beta.3

 

timeago.js

timeago.js is a simple library (only 1kb) to used to format datetime with `*** time ago` statement. eg: '3 hours ago'. localization supported.. Latest version: 4.0.2, last published: 3 years ago. Start using timeago.js in your project by running `npm i tim

www.npmjs.com

https://github.com/hustcc/timeago.js/blob/master/README.md

 

GitHub - hustcc/timeago.js: :clock8: timeago.js is a tiny(2.0 kb) library used to format date with `*** time ago` statement.

:clock8: :hourglass: timeago.js is a tiny(2.0 kb) library used to format date with `*** time ago` statement. - GitHub - hustcc/timeago.js: :clock8: timeago.js is a tiny(2.0 kb) library used to form...

github.com

 

728x90

댓글