# Formatdate markdown content

**URL:** <https://discuss.elastic.co/t/formatdate-markdown-content/270585>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [April 19, 2021, 1:29pm UTC](https://discuss.elastic.co/t/formatdate-markdown-content/270585 "2021-04-19T13:29:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![accateo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/accateo/32/85332_2.png) [@accateo](https://discuss.elastic.co/u/accateo)\
**Post date:** [April 19, 2021, 1:29pm UTC](https://discuss.elastic.co/t/formatdate-markdown-content/270585/1 "2021-04-19T13:29:23Z")

</div>

Hi,  
I have a markdown content in Canvas like this:

```auto
{{#each rows}}
### {{date}} ###
{{/each}}

```

where date is, for example:

2021-04-19T13:25:00+02:00

how can i format this date (d/m/y hh:mm) and set the local timezone?

Thanks

---

<div class="post-metadata">

**Author:** ![tiagocosta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tiagocosta/32/40045_2.png) [@tiagocosta](https://discuss.elastic.co/u/tiagocosta)\
**Post date:** [April 19, 2021, 9:24pm UTC](https://discuss.elastic.co/t/formatdate-markdown-content/270585/2 "2021-04-19T21:24:00Z")

</div>

@accateo I believe setting that date on canvas linked to the current browser local timezone is not possible yet. The best you can do is using `formatdate`to format the date and math operations to add or substract on the date itself. For example the example below with subtract an hour on the date being shown:

```auto
date | math "subtract(value, 3600000)" | formatdate format="MMMM YYYY"

```

More information about this issue can be found at [[Canvas] Display timestamp in the browser's timezone · Issue #33959 · elastic/kibana · GitHub](https://github.com/elastic/kibana/issues/33959)

---

<div class="post-metadata">

**Author:** ![accateo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/accateo/32/85332_2.png) [@accateo](https://discuss.elastic.co/u/accateo)\
**Post date:** [April 20, 2021, 8:01am UTC](https://discuss.elastic.co/t/formatdate-markdown-content/270585/3 "2021-04-20T08:01:00Z")

</div>

I have this...

 ![Cattura](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7eac5f67e5e25e70d20dd548f4be87429315fd3d.png)

---

<div class="post-metadata">

**Author:** ![tiagocosta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tiagocosta/32/40045_2.png) [@tiagocosta](https://discuss.elastic.co/u/tiagocosta)\
**Post date:** [April 20, 2021, 2:12pm UTC](https://discuss.elastic.co/t/formatdate-markdown-content/270585/4 "2021-04-20T14:12:34Z")

</div>

@accateo please look into your expression editor. You are probably not exposing date param in the data that reaches the markdown function

---

<div class="post-metadata">

**Author:** ![accateo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/accateo/32/85332_2.png) [@accateo](https://discuss.elastic.co/u/accateo)\
**Post date:** [April 20, 2021, 3:06pm UTC](https://discuss.elastic.co/t/formatdate-markdown-content/270585/5 "2021-04-20T15:06:27Z")

</div>

![Cattura](https://us1.discourse-cdn.com/elastic/original/3X/7/d/7d19a2e777806697185a0c9c69dd8404ebe1c63b.png)

I don't understand the problem...

---

<div class="post-metadata">

**Author:** ![corey.robertson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corey.robertson/32/54611_2.png) [@corey.robertson](https://discuss.elastic.co/u/corey.robertson)\
**Post date:** [April 20, 2021, 4:06pm UTC](https://discuss.elastic.co/t/formatdate-markdown-content/270585/6 "2021-04-20T16:06:23Z")

</div>

@accateo

You are receiving that error because you are passing the output of the `markdown` function and passing that into the `math` function, which doesn't work.

I think to accomplish what you are looking for, you should add a new column to your essql result that will contain the formatted date.

You can do that by doing something like

```auto
filters 
| essql ....
| mapColumn name="formatted_date" expression={getCell "date" | math "subtract(value, 3600000)" | formatdate format="MMM DD YYYY hh:mm:ss z"}
| markdown "{{#each rows}} {{formatted_date}} {{/each}}

```

The bug with format date is that it takes in what it assumes is a utc date, creates a localized date, but then assumes that localized date is utc. So, if you are UTC +5, and you give it a UTC time of 04:00:00, it's incorrectly going to format that to 09:00:00, so you would need to subtract those 5 hours off of the input date to get it formatted correctly, like @tiagocosta mentioned above.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 18, 2021, 4:06pm UTC](https://discuss.elastic.co/t/formatdate-markdown-content/270585/7 "2021-05-18T16:06:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
