I want to add this plugin.
https://timeago.yarp.com/
I did:
But time still the same:
It should show 14 years ago.
Please help. Why is it not working?
I want to add this plugin.
https://timeago.yarp.com/
I did:
But time still the same:
It should show 14 years ago.
Please help. Why is it not working?
Delete the links in your after content, the jquery will be loaded as you have it turned on in your settings
then in your design tab, right click on javascript and link External javascript
then add https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.2/timeago.min.js to the url
Make sure that the include order of your javascripts (again right click on javascript in design tab) has the external link before your actual script
Also, if you are not using jquery for anything else you could use this script:
function timeSince(date) {
var seconds = Math.floor((new Date() - date) / 1000);
var interval = seconds / 31536000;
if (interval > 1) {
return Math.floor(interval) + " years";
}
interval = seconds / 2592000;
if (interval > 1) {
return Math.floor(interval) + " months";
}
interval = seconds / 86400;
if (interval > 1) {
return Math.floor(interval) + " days";
}
interval = seconds / 3600;
if (interval > 1) {
return Math.floor(interval) + " hours";
}
interval = seconds / 60;
if (interval > 1) {
return Math.floor(interval) + " minutes";
}
return Math.floor(seconds) + " seconds";
}
And call it using: timeSince(new Date('1968-06-02T03:24:00'))
In the database the date format is like this: 30 July 2022 at 19:33:18 UTC
How can I change it to your format?
Ok I used timeSince(new Date(result[i].get('updatedAt').toISOString().slice(0, -5)))
and it works now.