time-utils-pro
v0.0.2
Published
Time utils
Readme
Sure, here is the README.md file in English. I've enclosed it in a code block for easy copying:
# time-utils-pro
`time-utils-pro` is a JavaScript package for easy manipulation of the current time. It offers functions for getting the current hour, minute, day, month, and year, as well as formatting dates and times according to various patterns.
## Installation
To use this package in your project, install it using npm:
```bash
npm install time-utils-proUsage
After installing, you can import and use the package in your JavaScript project. Here’s an example of how to use each function:
Importing the Package
const timeUtils = require('time-utils-pro');
// or, if you're using ES modules
import * as timeUtils from 'time-utils-pro';Functions
getCurrentDateTime()
Returns the current time as a Date object.
const currentDateTime = timeUtils.getCurrentDateTime();
console.log(currentDateTime); // For example: 2024-07-29T12:34:56.789ZgetHour()
Returns the current hour.
const hour = timeUtils.getHour();
console.log(hour); // For example: 12getMinute()
Returns the current minute.
const minute = timeUtils.getMinute();
console.log(minute); // For example: 34getDay()
Returns the current day of the month.
const day = timeUtils.getDay();
console.log(day); // For example: 29getMonth()
Returns the current month (1-12).
const month = timeUtils.getMonth();
console.log(month); // For example: 7getYear()
Returns the current year.
const year = timeUtils.getYear();
console.log(year); // For example: 2024formatDateTime(format)
Formats the date and time according to the given pattern. Supported patterns include:
YYYY- YearMM- Month (zero-padded)DD- Day (zero-padded)HH- Hours (zero-padded)mm- Minutes (zero-padded)ss- Seconds (zero-padded)
const formattedDate = timeUtils.formatDateTime('YYYY-MM-DD HH:mm:ss');
console.log(formattedDate); // For example: 2024-07-29 12:34:56Examples
const timeUtils = require('time-utils-pro');
console.log('Current Hour:', timeUtils.getHour());
console.log('Current Minute:', timeUtils.getMinute());
console.log('Current Day of the Month:', timeUtils.getDay());
console.log('Current Month:', timeUtils.getMonth());
console.log('Current Year:', timeUtils.getYear());
console.log('Formatted Time:', timeUtils.formatDateTime('DD/MM/YYYY HH:mm'));Contributing
If you would like to contribute to the project, you can submit a pull request or open an issue if you encounter any problems. Please make sure to review existing issues and discuss your proposed changes before adding new features or fixes.
License
This project is licensed under the MIT License.
Contact
For more information or inquiries, please contact me at [email protected].
Thank you for using time-utils-pro! If you have any questions or suggestions, feel free to reach out.
