get-formatted-date
v1.0.3
Published
Get formatted date with zero dependencies!
Downloads
6
Maintainers
Readme
Get Formatted Date
Get formatted date with zero dependencies!
Installation
# With yarn
$ yarn add get-formatted-date
# With npm
$ npm i get-formatted-date
Which Functions Included ?
getDate()
getYesterday()
getTomorrow()
Example Usage
Basic Usage
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
Detailed Usage
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
Options
| 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 |
Todo
- [x] Create the code!
- [X] Make a NPM Package
- [ ] Configure for cdn usage
- [ ] Add DDMMYYYY etc. support
- [ ] Add webpack | Gulp | Rollup
Contributing
If you've ever wanted to contribute to open source, and a great cause, now is your chance!