@michaelcj/datelib
v1.26.0
Published
lib to format dates
Downloads
22
Readme
DATE LIB
date lib is a date formatting library in Typescript
Installation
npm i @michaelcj/datelib
Usage
Short date formatting
# returns a short date with format 'Returns unformatted date in the form of [day month year]' ex 18 Jun 2022
import { getShortDate } from "@michaelcj/datelib";
<p>{getShortDate(new Date(2018, 11, 24, 10, 33, 30, 0))}</p>
# returns '24 Dec 2018'
# returns a short date with format 'Returns unformatted date in the form of [weekday day month year]' ex Monday 18 Jun 2022
import { getShortDateWithDay } from "@michaelcj/datelib";
<p>{getShortDateWithDay(new Date(2018, 11, 24, 10, 33, 30, 0))}</p>
# returns 'Monday 24 Dec 2018'
Relative time to now
# Returns time from or to a date in the format [x day|month|minutes|years from|to) now] ex 10 minutes ago | 10 years ago
import { getTimeFrameFromNow } from "@michaelcj/datelib";
<p>{getTimeFrameFromNow(new Date(2018, 11, 24, 10, 33, 30, 0))}</p>
# returns '4 years ago'
Localisation
Locale can be passed as an argument to each function. Current supported are EN and ES Passing nothing will default to EN