js-clock-utils
Version:
A simple JavaScript clock utility to get the current time in HH:MM:SS format.
54 lines (34 loc) ⢠1.21 kB
Markdown
# š js-clock-utils
A lightweight JavaScript utility library for working with clocks, time formatting, and relative timestamps. Designed for use in web apps, Node.js scripts, and anywhere you need simple time utilities.
## ⨠Features
- ā° Get the current time in `HH:MM:SS` format
- š Calculate time difference between two hours
- š
Fetch the current timestamp in ISO 8601 format
- š§ Display how long ago a date was ("5 minutes ago", etc.)
## š¦ Installation
```bash
npm install js-clock-utils
```
## š Usage
```bash
import clockUtils from 'js-clock-utils';
// Get current time
console.log(clockUtils.getCurrentTime()); // "14:05:09"
// Get difference in hours
console.log(clockUtils.getTimeDifferenceBetween(5, 8)); // "3 hrs"
// Get current ISO timestamp
console.log(clockUtils.getCurrentTimestamp()); // "2025-04-22T11:05:23.456Z"
// Get relative time
console.log(clockUtils.getTimeAgo('2025-04-22T10:00:00Z')); // "1 hour ago"
```
## š©āš» Author
One tick at a time ā ā handcrafted ā¤ļø by Manisha
## š License
MIT License
## š¬ Friendly
š” Curious for more? Check out what Iām building on GitHub https://github.com/manishaac2002!