So i am trying to learn Quasar and Vue by building a Twitter clone from a freecodecamp tutorial and all was well until i tried to convert a unix timestamp with date-fns into a relative time like e.g. “5 Minutes ago” to display the time passed since a tweet was posted. The exact code looks like this:
This is the Object i want to display in the upper right corner to indicate the time
<q-item-section side top>
{{ tweet.date | relativeDate }}
</q-item-section>
further down i implemented the function to filter the dates into the expected format inside the export default function
filters: {
relativeDate(value) {
return formatDistance(value, new Date())
}
}
There is legit nothing else happening here and i don´t get the promised String from date-fns function but a difference of the unix times, which i can calculate without date-fns for myself anyway ^^´.
I don´t get any errors only the wrong value. If you need any other infos please let me know and thanks in advance for any help.
I tried other functions like formatDistanceToNow() from date-fns but still got no correct value. Also i am building in quasar vue using typescript but turned the lang setting for this script section off because typescript didn´t accept the properties of the changed value when i piped the function into the object parenthesis. I don´t get any errors when i use js instead of ts and everything else still works.