gettine datetime string from new date in javascript code example
Example 1: string date to date in javascript
var ts = '1471793029764';
ts = Number(ts); // cast it to a Number
var date = new Date(ts); // works
var invalidDate = new Date('1471793029764'); // does not work. Invalid Date
Example 2: js datetime format
new Date().toISOString().slice(0, 16).replace("T", " ")