Date.parse

Syntax

PP.Date.parse(date, format, strict): Date;

Parameters

date. String | Number | Date. Date string value.

format. String | PP.Date.Pattern. The format, to which the date should be converted.

strict. Boolean. Indicates if to check date for correctness. By default the property is set to false.

Description

The parse static method returns date from the specified string by the specified formatting template.

Comments

Date string value can be created by means of the PP.Date.format method.

If time zone is not specified, the time is considered as local.

Example

To execute the example, add a link to PP.js scenario file to HTML page.

// Create date in the string format
date = "2016-09-05T11:24:21.453+05:00";
// Set date format
format = PP.Date.Pattern.Default;
// Convert string to date format
newDate = PP.Date.parse(date, format);
console.log(newDate);

After executing the example a date object if obtained from the string.

See also:

PP