Postgres Function To Get Current Timestamp Javascript For Loop