This is documentation for the next version of Grafana. For the latest stable release, go to the latest version.

API Reference@grafana/dataparse

dateMath.parse() function

dateMath.parse() function

Parses different types input to a moment instance. There is a specific formatting language that can be used if text arg is string. See unit tests for examples.


export declare function parse(text?: string | DateTime | Date | null, roundUp?: boolean, timezone?: TimeZone): DateTime | undefined;


import { dateMath } from '@grafana/data';
const { parse } = dateMath;


Parameter Type Description
text string | DateTime | Date | null
roundUp boolean See parseDateMath function.
timezone TimeZone Only string ‘utc’ is acceptable here, for anything else, local timezone is used.


DateTime | undefined