简体   繁体   中英

How to Conversion from “datetime-local” to mysql.Timestamp in javascript

I'm trying to insert date value from "date-time-local" box to MySQL DB in TIMESTAMP column. How should I convert the value to TIMESTAMP.

The JavaScript statement new Date().toISOString().slice(0, 19).replace('T', ' '); would yield something like 2019-03-11 03:47:06 . The MySQL TIMESTAMP value has a range from '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC, hence where you hear about the 2038 problem, since the integers can only cover so much space, but that's off topic :)

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