Search code examples
mysqlnode.jsnode-mysql

node-mysql changes Date.now() as if we are in 1970


I am using node-mysql. I keep last operation time in miliseconds in db.

Everything is fine however when i monitor the process through node-inspector timestamp is right but when it is saved into db it turns into this value 2147483647

Which is equal to Sun Jan 25 1970 23:31:23 GMT+0300 (MSK)

Column is formatted as int(20) i cant understand why it happens this way


Solution

  • The 'timestamp' you have is the maximum value for INT(), see the mysql documentation.

    You should change the column to BIGINT() to be able to store timestamps with ms precision.