Check if it is valid date string
var timestamp=Date.parse('foo') if (isNaN(timestamp)==false) { var d=new Date(timestamp); }