How to save JS Date.now() in PostgreSQL?

前端 未结 3 2102
野的像风
野的像风 2021-02-04 01:17

I tried to use PostgreSQL timestamp datatype, but it throws an error

ERROR:  date/time field value out of range: \"1489849402536\"

3条回答
  •  孤街浪徒
    2021-02-04 02:22

    Use the to_timestamp() postgres function:

    `insert into times (time) values (to_timestamp(${Date.now()} / 1000.0))`
    

提交回复
热议问题