recoder-code
Version:
🚀 AI-powered development platform - Chat with 32+ models, build projects, automate workflows. Free models included!
49 lines (29 loc) • 1.11 kB
Markdown
> Parse Postgres interval columns
```
$ npm install --save postgres-interval
```
```js
var parse = require('postgres-interval')
var interval = parse('01:02:03')
//=> {hours: 1, minutes: 2, seconds: 3}
interval.toPostgres()
// 3 seconds 2 minutes 1 hours
interval.toISO()
// P0Y0M0DT1H2M3S
```
*Required*
Type: `string`
A Postgres interval string.
Returns an interval string. This allows the interval object to be passed into prepared statements.
Returns an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Durations) compliant string.
Also available as `interval.toISO()` for backwards compatibility.
MIT © [Ben Drucker](http://bendrucker.me)