Hi,
I have a markdown content in Canvas like this:
{{#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
Hi,
I have a markdown content in Canvas like this:
{{#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
@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:
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
@accateo please look into your expression editor. You are probably not exposing date param in the data that reaches the markdown function
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
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.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.