nestjs-date-format-interceptor
Easy formatting for output dates in NestJS
This NPM provides an easy way to give a format to api response dates in NestJs
How to install.
npm install nestjs-date-format-interceptor
Binding in controller
; // ...
Binding globally
; // ... ; app.useGlobalInterceptorsnew DateFormatInterceptor;
Parameter options
- maxDeep: Max deep of nested objects to check dates
- format: The format function to build the date-string
- fnFormat?: Optional, Custom format function.
format options
Format | Result |
---|---|
toDateString | "Tue Aug 19 1975" |
toISOString | "1975-08-20T05:15:30.000Z" |
toJSON | "1975-08-20T05:15:30.000Z" |
toString | "Tue Aug 19 1975 23:15:30 GMT-0600 (Central Standard Time)" |
toTimeString | "23:15:30 GMT-0600 (Central Standard Time)" |
toUTCString | "Wed, 20 Aug 1975 05:15:30 GMT" |
fnFormat Custom format example
; ... ; app.useGlobalInterceptors new DateFormatInterceptor,;
Result:Date in Costa Rica is 7/14/2020, 8:01:15 PM
Author
- Luis Arias ariassd@gmail.com - GitHub profile