A
A
Alexander2016-08-23 13:43:54
MySQL
Alexander, 2016-08-23 13:43:54

How to write time in mysql from nodejs?

Nodejs has a variable in the form of number of milliseconds (since 70...). How to convert this time for writing in a timestamp field in mysql?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Belyaev, 2016-08-23
@bingo347

new Date(timestamp).toISOString()
will return a string in the unified international ISO format
such a string can be inserted into any MySQL fields whose data type is time

S
SagePtr, 2016-08-23
@SagePtr

Another option is to use the MySQL FROM_UNIXTIME function. Just remember that in javascript in milliseconds, and the function takes an argument in seconds.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question