Trevor Trevor - 1 year ago 357
Javascript Question

Convert postgres timestamp (+ timezone) to Date object [Javascript]

Our postgres database returns a string with a timestamp:


We are trying to use the
library, but it only accepts a Date object.

How can I convert the above timestamp+timezone into a Date object using Javascript?

Thank you for any help you can provide.

Answer Source

I needed to use moment(some_date).fromNow()

Instead of moment.startOf(some_date).fromNow()

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download