Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

nice-dates

ikejs12ISC1.2.1

Date formatter with more date methods!

date, formatter, time, sorter, sort, consecutive, past, present, future, organize

readme

nice-dates

Date formatter with more date methods!

alt text alt text alt text

Installation

npm i nice-dates --save

Date Formatting

const { timeAgoUntil } = require('nice-dates');

timeAgoUntil(new Date('2020-11-08T07:00:00.000Z')) // just now
timeAgoUntil(new Date('2020-11-08T06:59:32.000Z')) // 28 seconds ago
timeAgoUntil(new Date('2020-11-07T04:23:15.000Z')) // yesterday
timeAgoUntil(new Date('2020-11-11T02:15:07.000Z')) // 3 days from now
timeAgoUntil(new Date('2020-11-09T04:23:15.000Z')) // tomorrow
timeAgoUntil(new Date('2018-10-08T04:23:15.000Z')) // 2 years ago

Methods

  • timeAgoUntil(<date>) Returns the time ago/until the date.

  • consecutiveDates(<date>, <repeat>, <offset>) Returns an array of consecutive dates with an offset for each day.

  • orderDates([<dates>]) Puts a list of dates in order.

  • pastPresentFuture([<dates>]) Returns an object with arrays for past, present and future dates.