It depends on what you want to achieve.
If the goal is to add time range info somewhere in dashboard:
- Add “Text” panel and use “html” mode in panel options editor
- Put your html markup like this in panel Content
Custom dashboard time range info returned by function will be added here.<br>
var tr = angular.element('grafana-app').injector().get('timeSrv').timeRange();
return ['Current dashboard time range: from <', tr.from._d, '> to <', tr.to._d, '>'].join('');
Note, that it won’t give you time range as variable to be used like template variables in panels.