You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TimelyDiff is a JavaScript package that converts Unix timestamps into human-readable time differences. It allows you to easily display the time difference between two points in time in a user-friendly manner.
> To generate a timestamp at the current moment and store it for later use, you can use the built-in JavaScript function Date.now(), which returns the number of milliseconds since January 1, 1970, 00:00:00 UTC (Unix timestamp).
37
+
38
+
<br>
39
+
40
+
Optionally, you can pass a second parameter to the function to specify the length of the output string. By default, the function will return a string in the format of x [unit] ago/in [x][unit], but you can choose to return a shorter string by setting the length parameter to "short" or "shorter".
Converts a Unix timestamp into a human-readable time difference.
55
+
56
+
Parameters
57
+
-**`timestamp (number)`** - The Unix timestamp to convert.
58
+
-**`length (string)`** - Optional. The length of the output string. Can be set to **`"short"`** or **`"shorter"`** to return a shorter string. Defaults to **`null`**.
59
+
60
+
Returns
61
+
A string representing the time difference between the current time and the given timestamp.
62
+
63
+
<br>
64
+
65
+
### License
66
+
TimelyDiff is released under the **MIT License**.
67
+
68
+
<br>
69
+
70
+
### Contribution
71
+
Contributions are welcome and appreciated! If you have an idea for an improvement or a bug fix, please feel free to open an issue or submit a pull request. Before submitting a pull request, please ensure that your code follows the existing code style and has been thoroughly tested. Thank you for helping to make TimelyDiff even better!
0 commit comments