> For the complete documentation index, see [llms.txt](https://devworkshops.gitbook.io/masteringvuejs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devworkshops.gitbook.io/masteringvuejs/getting-started/filters.md).

# Filters

### Friendly date format

You might have noticed that there is an unused **created** property in our todo items. This is the date/time the todo item was created. Update as follow below to display the created date/time:

{% code title="index.html" %}

```markup
...
<label class="form-check-label" :for="'todo' + index" :class="{ done: todo.done }">
    {{ todo.title }}
    <br/>
    <small>{{todo.created}}</small>
</label>
...
```

{% endcode %}

If you save your changes and refresh the browser, you will see the same results below. Not great. We need to fix the formatting and to do that we will use a filter.

![](/files/-LfsDXNruW0yJFcKcBnN)

In the **main.js** file we're going to create a new filter as below to simply format that ugly date into something more friendly.

{% code title="main.js" %}

```javascript
Vue.filter("friendly-date", date => {
  var diff = new Date() - date;
  if (diff < 1000) return "Just now";
  if (diff < 60000) return `${Math.floor(diff / 1000)} seconds ago`;
  if (diff < 60000 * 60) return `${Math.floor(diff / 60000)} minutes ago`;
  return "Too long ago";
});
...
```

{% endcode %}

To use the filter, we append the pipe "|" symbol and the filter name as displayed below:&#x20;

{% code title="index.html" %}

```markup
...
<small>{{todo.created | friendly-date}}</small>
...
```

{% endcode %}

Save your changes and refresh the browser to see the new behaviour:

![](/files/-LfsEqgF69sxyseUUNQR)

And when you add a new item, you will see the date changing per item:

![](/files/-LfsF6VBstTCiFJKZEvL)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://devworkshops.gitbook.io/masteringvuejs/getting-started/filters.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
