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 stringval = '01/03/2012';
2var testdate;
3
4try {
5 testdate = $.datepicker.parseDate('mm/dd/yy', stringval);
6 // Notice 'yy' indicates a 4-digit year value
7} catch (e)
8{
9 alert(stringval + ' is not valid. Format must be MM/DD/YYYY ' +
10 'and the date value must be valid for the calendar.';
11}
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