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.

Signature

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

Import

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

Parameters

ParameterTypeDescription
textstring | DateTime | Date | null
roundUpbooleanSee parseDateMath function.
timezoneTimeZoneOnly string ‘utc’ is acceptable here, for anything else, local timezone is used.
fiscalYearStartMonthnumber

Returns:

DateTime | undefined