Convert string to date in javascript

Reading time: less than 1 minute

Convert string to date in javascript

How can I convert a string to date in js?

var mydate = new Date('2016-06-27');
var mydatetime = new Date('2016-06-27T11:51:00');

console.log(mydate);
console.log(mydatetime);