Skip to content

Function: asDate()

asDate(options): TTransformer<Date, TDate>

Create a date transformer. Using Tempo to parse and format date string.

Parameters

ParameterTypeDescription
optionsTempoOptions & DateOptionsTempoOptions for parsing/formatting and DateOptions for validation

Returns

TTransformer<Date, TDate>

Remarks

Without format option, asDate expects ISO 8601 format

Example

ts
// Default expect ISO 8601 format
Column('createdAt', asDate());
// With custom format and timezone
Column('createdAt', asDate({
  format: 'DD/MM/YYYY',
  timezone: 'Asia/Bangkok'
}));

Defined in

src/transformer/as-date.ts:46

Released under the MIT License.