To convert a MySQL date to JavaScript, use Date.parse.
Example
You can try to run the following code to convert MySQL date to JavaScript date −
<!DOCTYPE html> <html> <body> <script> var MySQL_date = '2017-12-31 11:55:17'; document.write("MySQL Date: "+MySQL_date); var jsDate = new Date(Date.parse(MySQL_date.replace(/[-]/g,'/'))); document.write("<br>JavaScript Date: "+jsDate); </script> </body> </html>
Output
MySQL Date: 2017-12-31 11:55:17 JavaScript Date: Sun Dec 31 2017 11:55:17 GMT+0530 (India Standard Time)