svelte-date-component

1.2.2 • Public • Published

svelte-date-component

A svelte component for displaying the amount of elapsed time since a given date.

Usage

Add it to your svelte project:

$ npm i svelte-date-component --save

Then, pop it into the component that suites you:

<script>
    import Elapsed from 'svelte-date-component';
    let date = new Date().getTime();
</script> 
 
<Elapsed mils={date}/>

As you can see svelte-date-component has only one prop: mils of type number.

The above example would display this:

Just now

... until 3 seconds has elapsed, then it would display:

4 seconds ago

This example...

<script>
    import Elapsed from 'svelte-date-component';
    let date = new Date().getTime() - 1000 * 60 * 60 * 24; // One day before now
</script> 
 
<Elapsed mils={date}/>

...displays this:

About a day ago

Bugs

Found an problem? Submit an issue, or ping me on Discord: Vehmloewff#0724.

/svelte-date-component/

    Package Sidebar

    Install

    npm i svelte-date-component

    Weekly Downloads

    1

    Version

    1.2.2

    License

    MIT

    Unpacked Size

    4.88 kB

    Total Files

    5

    Last publish

    Collaborators

    • vehmloewff