[javascript] Javascript - Regex to validate date format

@mplungjan, @eduard-luca

function isDate(str) {    
    var parms = str.split(/[\.\-\/]/);
    var yyyy = parseInt(parms[2],10);
    var mm   = parseInt(parms[1],10);
    var dd   = parseInt(parms[0],10);
    var date = new Date(yyyy,mm-1,dd,12,0,0,0);
    return mm === (date.getMonth()+1) && 
        dd === date.getDate() && 
        yyyy === date.getFullYear();
}

new Date() uses local time, hour 00:00:00 will show the last day when we have "Summer Time" or "DST (Daylight Saving Time)" events.

Example:

new Date(2010,9,17)
Sat Oct 16 2010 23:00:00 GMT-0300 (BRT)

Another alternative is to use getUTCDate().