# time_diff_human_readable

> Convert database time/js timestamp and calculate difference between both times and output in human readable format. e.g 2 mins ago

Latest version **1.0.2** (published 2023-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install time_diff_human_readable
pnpm add time_diff_human_readable
yarn add time_diff_human_readable
bun add time_diff_human_readable
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-01-17 |
| First published | 2023-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Emperorx3m |
| Maintainers | emperorx3m |
| Keywords | time, difference, time, difference, timestamp, convert, time, time, convert, human, readable, time, difference, isostring, human, readable, datetime, difference, datetime, difference |

## Links

- npm: https://www.npmjs.com/package/time_diff_human_readable
- Repository: Time_diff_human_readable
- npm.io page: https://npm.io/package/time_diff_human_readable

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2023-01-17
- 1.0.1 — 2023-01-17

## README

# Human Readable Time Difference

Human Readable Time Difference is a lightweight package for checking and displaying the difference between two timestamps. both past and future.

## Installation

- Use the [NPM package](https://www.npmjs.com/package/time_diff_human_readable).
-- npm i time_diff_human_readable
- Link directly to JsDelivr https://cdn.jsdelivr.net/npm/time_diff_human_readable@1.0.1/index.js
- Download and add to your project and Link directly.


## Usage
```html
humanTimeDiff(new Date(2022, 0, 1), new Date(2021, 0, 1));
// 1 year ago
humanTimeDiff(new Date(2022, 0, 1), new Date(2010, 0, 1));
// 12 years ago
humanTimeDiff(new Date(2022, 2, 20), new Date(2022, 0, 1));
// 2 months ago
humanTimeDiff("2023-01-17T13:23:19.293Z" , "2023-01-17T15:57:26.242Z");
2 hours ago
## Using Single Param will use date,now to compare difference
humanTimeDiff("2023-01-17T13:23:19.293Z");
//variable always uses date.now to compare

---------------------------------------------

```



```Javascript
#// ReactJS, Node etc.
simply import and use

import {humanTimeDiff} from "time_diff_human_readable";

//BASIC HTML

 <script type="module">
    import {humanTimeDiff} from "https://cdn.jsdelivr.net/npm/time_diff_human_readable@1.0.1/index.js"
    window.addEventListener('DOMContentLoaded', () => {
        var response = humanTimeDiff("2023-01-17T13:23:19.293Z");
        var response = humanTimeDiff("2023-01-17T13:23:19.293Z", new Date());
    })
</script>

```


### Requirements
* No dependencies, built with vanilla JS.
* A modern browser (ECMA 5 support, http://caniuse.com/use-strict).


## Troubleshooting

- In pure HTML Make sure you are setting "type module on the script tag - view html above"
- ONly valid dates and date time strings allowed.

## License

Licensed under the [MIT License](http://opensource.org/licenses/MIT).

## Github Page with demo

https://emperorx3m.github.io/Time_Diff_human_readable/

---
_Source: https://npm.io/package/time_diff_human_readable · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
