I tried to use PostgreSQL timestamp
datatype, but it throws an error
ERROR: date/time field value out of range: \"1489849402536\"
Or you can do something similar to this:
const time = new Date().toISOString();
In your query builder:
...
.update()
.set({column_name: time})
Use the to_timestamp() postgres function:
`insert into times (time) values (to_timestamp(${Date.now()} / 1000.0))`
Just in case you are using Sequelize, you can use: sequelize.literal('CURRENT_TIMESTAMP')
.
Example:
await PurchaseModel.update( {purchase_date : sequelize.literal('CURRENT_TIMESTAMP') }, { where: {id: purchaseId} } );