New to Kendo UI for jQuery? Download free 30-day trial

Date Parsing

Kendo UI exposes methods which convert a specified string to a Date object by using the culture-specific settings.

Parsing without Specifying Formats

The kendo.parseDate(string) method converts a string to a JavaScript Date object taking into account the set of default culture formats.

//current culture is "en-US"
kendo.parseDate("12/22/2000"); //Fri Dec 22 2000

Parsing by Specifying Formats

The kendo.parseDate(string, format) method converts a string to a JavaScript Date object taking into account the specified formats.

kendo.parseDate("2000/12/22", "yyyy/MM/dd");
kendo.parseDate("2000/12/22", ["MM/dd/yyyy", "yyyy/MM/dd"]);

Parsing by Specifying Format and Culture Names

The kendo.parseDate(string, format, cultureName) method converts a string to a JavaScript Date object by taking into account the specified formats and culture.

kendo.parseDate("2012.07.16", "yyyy/MM/dd", "de-DE");
kendo.parseDate("2012.07.16", ["MM/dd/yyyy", "yyyy/MM/dd"], "de-DE");
  • The kendo.parseDate() parses strings by incrementally matching an increasing portion of the date string until it satisfies the current corresponding format part. This may lead to unexpected results when parsing ambiguous date strings with no delimiters. For example, the parsing of 222015 with a dMyyyy format fails, because "22" is matched as d and that leaves no suitable string part for the month.
  • In addition, parsing is permissive and ignores invalid strings which occur after the year.

Parsing by Entirely Matching the Format

The kendo.parseExactDate(string, formats) method will parse a string as a date. If the string does not match the format entirely the method will return null.

kendo.parseExactDate("3/4/2013", "MM/dd/yyyy") // Outputs "Mon Mar 04 2013 00:00:00".
kendo.parseExactDate("3/4/2013", "MM/dd/yy") // Outputs "null".

Parsing UTC Date Strings

When parsing UTC date strings without providing a format string, the resulting JavaScript Date object renders the time according to the local time zone of the user.

kendo.parseDate("2016-02-14T06:15:44.123Z"); // Sun Feb 14 2016 08:15:44 GMT+0200 (FLE Standard Time)

When you use formats for parsing UTC date strings, apply the zzz specifier to render the local time. Otherwise, the current browser timezone offset will apply.

kendo.parseDate("2016-08-09T05:28:46Z", "yyyy-MM-ddTHH:mm:sszzz") // Tue Aug 09 2016 08:28:46 GMT+0300 (FLE Daylight Time)

See Also

In this article