1// There are two flavours
2const event = new Date(1993, 6, 28, 14, 39, 7);
3
4// The Old Skool Flava
5console.log(event.toString());
6// expected output: Wed Jul 28 1993 14:39:07 GMT+0200 (CEST)
7// (note: your timezone may vary)
8
9// The Hipster way ;)
10console.log(event.toDateString());
11// expected output: Wed Jul 28 1993
1var myDate = new Date("2013/1/16");
2
3var str = "2013/1/16";
4var strToDate = new Date(str);
1Date.parse(dateString)
2//dateString is like 2020-10-10 / 2020-10-10T10:20:20
1var parts ='2014-04-03'.split('-');
2// Please pay attention to the month (parts[1]); JavaScript counts months from 0:
3// January - 0, February - 1, etc.
4var mydate = new Date(parts[0], parts[1] - 1, parts[2]);
5console.log(mydate.toDateString());
1var ts = '1471793029764';
2ts = Number(ts); // cast it to a Number
3var date = new Date(ts); // works
4
5var invalidDate = new Date('1471793029764'); // does not work. Invalid Date
6