JavaScript
DatefromFormat Method
Syntax
Date.fromFormat(date[,format])
Arguments
- datestring
A formatted date.
- formatstring
The format the date is in. If no format is specified the default format in A5.d.date.format will be used
Description
Extension to the native date variable to set the date variable to the value of the passed in date string.
Discussion
This method parses a formatted date string to set the value in the date object. An optional format can be specified that defines the structure of the formatted date string.
See Date.toFormat for a full list of format values.
Example
var dStr = '21st Apr 2018 2:05 pm'; var d = new Date(); d.fromFormat(dStr,'x Mon yyyy h:0m am'); // d = Date(2018,3,21,14,5)