Parse date string to Date - Node.js String

Node.js examples for String:Parse

Description

Parse date string to Date

Demo Code

/**//from  w ww. ja va2 s .  c  o m
 * @param {string|Date|number} value
 * @return {number} timestamp
 */
number.parseDate = function (value) {
    return value instanceof Date
        ? value
        : new Date(
            typeof value === 'string'
                ? value.replace(/-/g, '/')
                : Math.round(value)
        );
};

Related Tutorials