@based/pretty-date
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Pretty date

Small package to nicely format a numerical date to a human readable date.

This package transform a numerical date into a human-readable format. There are several formats available.

Install

$ npm i @based/pretty-date

Usage

import { prettyDate } from '@based/pretty-date'

const time = Date.now() - 1e5 // a few minutes ago, as an epoch number

console.log(prettyDate(time,'date-time-human')) // => prints '17 minutes ago'
console.log(prettyDate(time,'date-time-text')) // => prints 'September 13, 2021, 9:37:44 AM'
console.log(prettyDate(time,'date-time')) // => prints '9:37 13/9/2021'
console.log(prettyDate(time,'date')) // => prints '13/9/2021'
console.log(prettyDate(time,'time')) // => prints '9:37'
console.log(prettyDate(time,'time-precise')) // => prints '9:37:44'

Package Sidebar

Install

npm i @based/pretty-date

Weekly Downloads

58

Version

1.0.4

License

MIT

Unpacked Size

12 kB

Total Files

8

Last publish

Collaborators

  • luiguild
  • nfrade
  • kylemarch513
  • framma
  • olliv
  • youzid
  • rase-
  • saulx