I've created a vue project for my assignment, and I want to show a formatted time on a section of the webpage. However, even after passing it through a filter, I'm still seeing the same unformatted epoch time.
I want to show the time on my webpage in a certain format, and therefore I've used a filter as such:
filters: {
niceDate(timeStamp) {
const dateObject = new Date(timeStamp * 1000);
const formattedDate = date.formatDate(dateObject, "MMMM D h:mm A");
return formattedDate;
},
},
I've also referenced this in the template like this:
<div class="text-caption text-grey">{{ post.date | niceDate }}</div>
Note that both the filter and template are from the same file (a Page file)
However, the result I see is still the epoch value from my object being shown instead of the formatted time:
{
id: 1,
user: "Tucker",
emotion: "happy",
location: "Mirihana, Sri Lanka",
date: 1710799030927, // This is what I see on the browser, but I want it to be formatted
caption: "I like biting people",
imgURL: "https://cdn.quasar.dev/img/parallax2.jpg",
},
EDIT: formatDate() is a utility function from Quasar FYI