Get formatted date with zero dependencies!
# With yarn
$ yarn add get-formatted-date
# With npm
$ npm i get-formatted-date
getDate()
getYesterday()
getTomorrow()
import { getDate, getYesterday, getTomorrow } from 'get-formatted-date';
const myDate = new Date() // Let's say new Date() is 05.01.2021 - 11:00
getDate({ date: myDate }); // Returns 05.08.2021
getYesterday({ date: myDate }); // Returns 04.08.2021
getTomorrow({ date: myDate }); // Returns 06.08.2021
import { getDate, getYesterday, getTomorrow } from 'get-formatted-date';
const myDate = new Date() // Let's say new Date() is 05.01.2021 - 11:00
getDate({ date: myDate, seperator: '/', hasHM: true, timeSeperator: '-', HMSeperator: '.' }); // Returns 05/01/2021 - 11.00
getYesterday({ date: myDate, seperator: '/', hasHM: true, timeSeperator: '-', HMSeperator: '.' }); // Returns 04/01/2021 - 11.00
getTomorrow({ date: myDate, seperator: '/', hasHM: true, timeSeperator: '-', HMSeperator: '.' }); // Returns 06/01/2021 - 11.00
Params | Type | Description |
---|---|---|
date |
Time value | Timestamp | Timestamp String | Default: new Date() For more info see this MDN document |
seperator |
String | Default: '.' Seperator between dates |
hasHM |
Boolean | Default: false Whether include Hour and Minute |
timeSeperator |
String | Default: '-' Seperator for date and time |
HMSeperator |
String | Default: ':' Seperator for hour and minute |
- Create the code!
- Make a NPM Package
- Configure for cdn usage
- Add DDMMYYYY etc. support
- Add webpack | Gulp | Rollup
If you've ever wanted to contribute to open source, and a great cause, now is your chance!