Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
149
rated 0 times [  155] [ 6]  / answers: 1 / hits: 47877  / 7 Years ago, sat, march 18, 2017, 12:00:00

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



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


The schema



create table times (
time timestamp not null,
);


JS code



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


P.S. another option is to use bigint but it seems like an overkill.


More From » postgresql

 Answers
2

Use the to_timestamp() postgres function:



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

[#58490] Thursday, March 16, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
citlalia

Total Points: 138
Total Questions: 104
Total Answers: 87

Location: Iceland
Member since Sat, Sep 17, 2022
2 Years ago
;