https://github.com/arshadkazmi42/custom-date-formatting
:calendar: Npm package for custom date formatting
https://github.com/arshadkazmi42/custom-date-formatting
date-formatting dates format-date formatting moment
Last synced: 3 days ago
JSON representation
:calendar: Npm package for custom date formatting
- Host: GitHub
- URL: https://github.com/arshadkazmi42/custom-date-formatting
- Owner: arshadkazmi42
- License: gpl-3.0
- Created: 2017-08-28T17:17:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-08-15T08:54:33.000Z (over 3 years ago)
- Last Synced: 2024-11-02T11:51:33.317Z (6 months ago)
- Topics: date-formatting, dates, format-date, formatting, moment
- Language: TypeScript
- Homepage:
- Size: 1.32 MB
- Stars: 6
- Watchers: 2
- Forks: 60
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Custom Date Formatting
[](https://travis-ci.org/arshadkazmi42/custom-date-formatting)
[](https://www.npmjs.com/package/customdateformating)
[](https://www.npmjs.com/package/customdateformating)
[](https://www.npmjs.com/package/customdateformating)
[](https://github.com/arshadkazmi42/custom-date-formatting/graphs/contributors)
[](https://github.com/arshadkazmi42/custom-date-formatting/commits/master)## How to install?
[](https://www.npmjs.com/package/customdateformating/)## Usage
### Custom Format date with Days (+/-)
Pass the format of the date required and numberOfDays to add from current day to the Function.
For previous days numberOfDays should be passed as negative value.
```javascript
// Create Instance of the DateValidator
const DateFormatting = require('custom-date-formatting');// This will return a string with new date
DateFormatting.getNextOrPrevDateCustomFormat("YYYY-MM-DD", 0);// Output: "2018-10-06"
```
### Custom Format date with Minutes (+/-)
Pass the format of date required and minutesToAdd to add/subtract minutes from current time to the Function.
For passed minute of time, minutesToAdd should be passed as negative value.
```javascript
// Create Instance of the DateValidator
const DateFormatting = require('custom-date-formatting');// This will return a string with new date and time
DateFormatting.getNextOrPrevMinuteDateCustomFormat("YYYY-MM-DD HH:mm", 1);// Output: "2018-10-06 00:39"
```### Custom Format date with Seconds (+/-)
Pass the format of date required and secondsToAdd to add/subtract seconds from current time.
For passed minute of time, secondsToAdd should be passed as negative value.
```javascript
// Create Instance of the DateValidator
const DateFormatting = require('custom-date-formatting');
// This will return a string with new date and time
DateFormatting.getNextOrPrevSecondDateCustomFormat("YYYY-MM-DD HH:mm:ss", 10);// Output: "2018-10-06 00:40:02"
```### Custom Source Format date custom new format
Pass the date (input date), currentFormat (input date format), newformat. (required date format)to the Function.
```javascript
// Create Instance of the DateValidator
const DateFormatting = require('custom-date-formatting');// This will return a string with date in new format
DateFormatting.customSourceDateFormatToCustomNewDateFormat("2017-08-28 23:22:00", "YYYY-MM-DD HH:mm:ss", "dddd DD MMM YYYY");// Output: "Monday 28 Aug 2017"
```### Timestamp from custom date format
Pass the date (input date), currentFormat (input date format)to the function.
```javascript
// Create Instance of the DateValidator
const DateFormatting = require('customdateformatting');// This will return input date value as timestamp in milliseconds.
DateFormatting.getTimeStampFromCurrentDateFormat("28 Aug 2017", "DD MMM YYYY");// Output: 1503858600000
```## Contributors
Thank you to all the contributors who have helped us in making this project better 🙌
## Contributing Guidelines
Read the contributing guidelines [here](CONTRIBUTING.md)