{"id":18675,"library":"postgres-date","title":"postgres-date","description":"A focused parser that converts PostgreSQL date/time output strings into JavaScript Date objects, preserving precision and matching Postgres behavior. Version 2.1.0 supports Node >=12 and includes TypeScript types. It is maintained as a patch-level library with no minor releases planned, releasing fixes only. Unlike heavier database clients, this is a minimal single-purpose tool for accurate date parsing.","status":"active","version":"2.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/bendrucker/postgres-date","tags":["javascript","postgres","date","parser","typescript"],"install":[{"cmd":"npm install postgres-date","lang":"bash","label":"npm"},{"cmd":"yarn add postgres-date","lang":"bash","label":"yarn"},{"cmd":"pnpm add postgres-date","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The module exports a single default function. Named import will not work.","wrong":"const { parse } = require('postgres-date')","symbol":"default","correct":"import parse from 'postgres-date'"},{"note":"CommonJS require returns the default export directly; no .default needed.","wrong":"const parse = require('postgres-date').default","symbol":"require (CommonJS)","correct":"const parse = require('postgres-date')"},{"note":"The default export is the parse function; named import parse does not exist.","wrong":"import { parse } from 'postgres-date'\nparse('2011-01-23 22:15:51Z')","symbol":"parse","correct":"import parse from 'postgres-date'\nparse('2011-01-23 22:15:51Z')"}],"quickstart":{"code":"import parse from 'postgres-date';\n\nconst dateString = '2023-12-25 10:30:00+02';\nconst date = parse(dateString);\nconsole.log(date.toISOString());\n// => 2023-12-25T08:30:00.000Z\n\n// With time zone offset\nconst date2 = parse('2023-01-01 00:00:00-05');\nconsole.log(date2.toISOString());\n// => 2023-01-01T05:00:00.000Z\n\n// Infinity dates\nconsole.log(parse('infinity')); // null\nconsole.log(parse('-infinity')); // null","lang":"typescript","description":"Demonstrates parsing various PostgreSQL date strings including timezone offsets and infinity values."},"warnings":[{"fix":"Check for null before using the result if your data may contain infinity dates.","message":"Infinity dates ('infinity', '-infinity') return null instead of a Date object.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Manually handle BC dates by adjusting the year: parse('0001-01-01 BC') will not give correct year.","message":"The parser does not handle BC dates (before Christ) correctly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure your Postgres session timezone is set to UTC or verify the offset before parsing.","message":"Parsing timestamps with time zone '00:00' will interpret as UTC, but Postgres may use different timezone offsets.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `import parse from 'postgres-date'` or `const parse = require('postgres-date')`.","cause":"Using named import `{ parse }` instead of default import.","error":"TypeError: (intermediate value)(...) is not a function"},{"fix":"Run `npm install postgres-date` and ensure tsconfig.json includes `node_modules` in moduleResolution.","cause":"Package not installed or TypeScript cannot resolve types.","error":"Cannot find module 'postgres-date' or its corresponding type declarations."},{"fix":"Check input dates and handle extremely large years manually.","cause":"Parsing a date string that is out of JavaScript's Date range (e.g., year 100000).","error":"RangeError: Invalid time value"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}