javascript string to date format code example
Example 1: js string to date
var myDate = new Date("2013/1/16");
var str = "2013/1/16";
var strToDate = new Date(str);
Example 2: string date to date in javascript
var ts = '1471793029764';
ts = Number(ts);
var date = new Date(ts);
var invalidDate = new Date('1471793029764');
Example 3: get date format javascript
const handleDate = (dataD) => {
let data= new Date(dataD)
let month = data.getMonth() + 1
let day = data.getDate()
let year = data.getFullYear()
if(day<=9)
day = '0' + day
if(month<10)
month = '0' + month
const postDate = year + '-' + month + '-' + day
return postDate
}