Get time from Time Range from custom plugin

I am trying to access the queried date range from within a plugin, so that I can do calculations based on the length of time being queried. Is there a way to do this?

In the past existed a timefilter service for angular for kibana 5:

https://github.com/lukasolson/kibana/blob/master/src/ui/public/timefilter/timefilter.js#L48

but the link is now unavailable.

Hi, are you trying to implement this in Kibana 5.x? The code to make this work today is going to be very different than how it worked in 5.x

In the master branch today, you can import timefilter from ui/timefilter:

import { timefilter } from 'ui/timefilter';

Then you have access to a singleton service where you have many methods for the time range. See: https://github.com/elastic/kibana/blob/master/src/legacy/ui/public/timefilter/timefilter.js

Example from Timelion timecharts:

1 Like

Thank you!

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