0👍
In Moment, you can check if a date is within the last 24 hours with:
moment().diff(yourDate, 'hours') < 24
(note that future dates will also pass this check, but you can easily adjust it).
You can put this into your computed property:
newTasks(){
if(!this.tasks){
return []
}
return this.tasks.filter(task => !task.done && moment().diff(task.creationDateTime, 'hours') < 24)
}
And that’s it, now newTasks
should contain all tasks from the last 24 hours that are not done.
- [Vuejs]-How to create a function to display an alert message after deleting data
- [Vuejs]-How to route user to particular div with Vue + Typescript?
Source:stackexchange.com