The code sample below shows how to compare a given date, in this case,
publishedDate to the current DateTime
now and get back the duration in a human-readable format.
01: <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script> 02: <script> 03: var now = moment(); 04: var publishedDate = moment(new Date('2022/04/01')); 05: console.log(moment.duration(publishedDate.diff(now)).humanize(true)); // 7 months ago 06: </script>
Here is another article you might like 😊 "GitHub: We weren’t able to create the release for you. Make sure you have a valid tag. (Fixed)"