Skip to content

A simple Svelte component to provide relative time in the "n{time} ago" format.

Notifications You must be signed in to change notification settings

takoyaro/svelte-timeago

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

svelte-timeago

A simple Svelte component to provide relative time in the n{unit} ago format.

How to use

Install the package: npm i svelte-timeago

Import the package

<script>
	import TimeAgo from 'svelte-timeago';
</script>

<TimeAgo date="2021-10-25 11:13:00" live/>

Props

date

Default: null Date should be a valid Date object, a valid UNIX timestamp or a valid date string, preferably in ISO-8601 format.

live

Default: false Should the displayed time update every 1 second?

withSuffix

Default: true Should the word ago be displayed after the time?

asPrefix

Default: true Should the suffix be a prefix instead? i.e. Il y à n{unit}

suffix

Default: ago The suffix used when withSuffix is set to true.

units

Default:

{
	seconds:'s',
	minutes:'m',
	hours:'h',
	days:'d',
	months:'mo',
	years:'y'
}

The units to be displayed. Can also be used to set your own locale. i.e. 時間 etc.

About

A simple Svelte component to provide relative time in the "n{time} ago" format.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages