# Get time from Time Range from custom plugin

**URL:** <https://discuss.elastic.co/t/get-time-from-time-range-from-custom-plugin/175800>\
**Category:** Kibana\
**Created:** [April 8, 2019, 8:58am UTC](https://discuss.elastic.co/t/get-time-from-time-range-from-custom-plugin/175800 "2019-04-08T08:58:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bard0x](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@bard0x](https://discuss.elastic.co/u/bard0x)\
**Post date:** [April 8, 2019, 8:58am UTC](https://discuss.elastic.co/t/get-time-from-time-range-from-custom-plugin/175800/1 "2019-04-08T08:58:02Z")

</div>

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](https://github.com/lukasolson/kibana/blob/master/src/ui/public/timefilter/timefilter.js#L48)

but the link is now unavailable.

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [April 8, 2019, 8:19pm UTC](https://discuss.elastic.co/t/get-time-from-time-range-from-custom-plugin/175800/2 "2019-04-08T20:19:44Z")

</div>

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`:

```auto
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](https://github.com/elastic/kibana/blob/master/src/legacy/ui/public/timefilter/timefilter.js)

Example from Timelion timecharts:

- [https://github.com/elastic/kibana/blob/master/src/legacy/core\_plugins/timelion/public/panels/timechart/schema.js#L175](https://github.com/elastic/kibana/blob/master/src/legacy/core_plugins/timelion/public/panels/timechart/schema.js#L175)
- [https://github.com/elastic/kibana/blob/master/src/legacy/core\_plugins/timelion/public/panels/timechart/schema.js#L273](https://github.com/elastic/kibana/blob/master/src/legacy/core_plugins/timelion/public/panels/timechart/schema.js#L273)

---

<div class="post-metadata">

**Author:** ![bard0x](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@bard0x](https://discuss.elastic.co/u/bard0x)\
**Post date:** [April 11, 2019, 9:35am UTC](https://discuss.elastic.co/t/get-time-from-time-range-from-custom-plugin/175800/3 "2019-04-11T09:35:23Z")

</div>

Thank you!

---

<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 9, 2019, 9:45am UTC](https://discuss.elastic.co/t/get-time-from-time-range-from-custom-plugin/175800/4 "2019-05-09T09:45:04Z")

</div>

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