Use date_part or extract to postgres to return a timestamp.
select date_part('epoch',mydatefield)*1000 from table;
Then you can simply send it directly, noting that the epoch is seconds since January 1, 1970, while JS wants milliseconds, thus *1000 . If you need this to be a date, as soon as you receive it in Javascript, you can convert it to a date by calling new Date(timestamp_from_pg) .
Note that the fleet can work with timestamps as numbers; you do not need to create Date objects.
Yley
source share