A polymer element that strategically updates its output based on the age of
time
. The default output is the relative time (e.g. 8 hours ago).
bower i -S jifalops/from-now # Polymer 2.0 class based
bower i -S jifalops/from-now#0.4.0 # Polymer 2.0 hybrid (1.x compatible)
bower i -S jifalops/from-now#0.3.0 # Polymer 1.x based
Simply give it a timestamp including milliseconds and it will output time relative to now in a human friendly format. It will also update the output according to how far away it is (e.g. once per day/hour/minute).
<from-now id="now1"></from-now> | default<br/>
<from-now id="now2" idle></from-now> | idle<br/>
<from-now id="now3" use-absolute></from-now> | absolute<br/>
<from-now id="now4" use-absolute format="YYYY-MM-DD HH:mm"></from-now> | formatted absolute<br/>
(mouseover for alternate format)
Full demo: webcomponents.org | github
API: webcomponents.org
- Fork it on Github.
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request