简体   繁体   中英

How to format new date object to MySQL format YYYY-MM-DD hh-mm-ss in core JavaScript?

How to format JavaScript date object to MySQL format YYYY-MM-DD hh-mm-ss ? I am trying send date to API what ever solution I get is to get data from API and format but I did not get any thing which format date to MySQL format.

PS

I know I can use moment.js but I want to do in core JavaScript.

I found below solution

 var mydate = new Date().toISOString().replace("T"," ").split(".")[0]; console.log(mydate)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM