Download Youtube-Clone/src/utils/date.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 682 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/Youtube-Clone/src/utils/date.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/Youtube-Clone/src/utils/date.js
-
curl -L -o date.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/Youtube-Clone/src/utils/date.js
682 Bytes
| function timeSince(date) { | |
| var seconds = Math.floor((new Date() - date) / 1000); | |
| var interval = seconds / 31536000; | |
| if (interval > 1) { | |
| return Math.floor(interval) + " year ago"; | |
| } | |
| interval = seconds / 2592000; | |
| if (interval > 1) { | |
| return Math.floor(interval) + " month ago"; | |
| } | |
| interval = seconds / 86400; | |
| if (interval > 1) { | |
| return Math.floor(interval) + " day ago"; | |
| } | |
| interval = seconds / 3600; | |
| if (interval > 1) { | |
| return Math.floor(interval) + " hour ago"; | |
| } | |
| interval = seconds / 60; | |
| if (interval > 1) { | |
| return Math.floor(interval) + " minute ago"; | |
| } | |
| return Math.floor(seconds) + " seconda ago"; | |
| } | |
| export default timeSince; | |