lodemon-utils
v1.0.2
Published
A date-time utility library for Node.js
Downloads
10
Readme
📅 My Utils - Date & Time Utility Library
My Utils is a simple and lightweight Node.js library for handling date and time operations with ease. It provides functions for getting the current date-time, calculating time differences, modifying dates, and converting timezones.
🚀 Installation
You can install My Utils via npm:
npm install my-utils📖 Usage
Import the library into your project:
const dateUtils = require('my-utils');
// Get current date-time
console.log(dateUtils.getCurrentDateTime());
// Calculate time difference between two dates
const diff = dateUtils.getTimeDifference('2025-04-01', '2025-03-01');
console.log(`Time difference: ${diff} days`);
// Modify a date by adding days
console.log(dateUtils.modifyDate('2025-04-01', 5));
// Convert timezone
console.log(dateUtils.convertTimezone('2025-04-01 12:00:00', 'America/New_York'));📜 API Reference
getCurrentDateTime(format = 'YYYY-MM-DD HH:mm:ss')
Returns the current date and time in the specified format.
getTimeDifference(date1, date2, unit = 'days')
Returns the difference between two dates in the specified unit (e.g., days, hours, minutes).
modifyDate(date, amount, unit = 'days')
Modifies a given date by adding or subtracting time units.
convertTimezone(date, timezone = 'UTC')
Converts a given date to a specified timezone.
🛠 Development & Testing
To run tests, install Jest and execute:
npm test📜 License
This project is licensed under the ISC License.
👤 Author
Developed by Lodemon.
Enjoy using My Utils! 🚀
